1

I'm trying to sort a column such as :

<td> <span class="badge badge-light">300 €</span>  [email protected] </td>

Where the content of the badge (300 €) is the amount I want to be used for the sort.

Without the badge, the sort is working without problem, but it doesn't seem to work with the badge.

1 Answer 1

2

SOLUTION 1

See columns.type option which you can set to 'html' to have HTML tags removed for ordering and searching.

SOLUTION 2

Alternatively you can tell DataTables value you want to use for sorting using data- attributes, see HTML5 data-* attributes - cell data.

For example:

<td data-order="300"> <span class="badge badge-light">300 €</span>  [email protected] </td>
Sign up to request clarification or add additional context in comments.

1 Comment

Solution 2 worked perfectly. Solution 1 blocked the sorting for some reason, thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.