Sort by custom data attribute on a <td>?
See original GitHub issueHi, I read a couple issues about people trying to do (I think) the same thing I am: #500, #546.
I am creating an html table, and I want to sort a column by a custom attribute instead of the actual contents of the
I thought this is what data-sort-name column option is for, but I can’t get it to work.
For example:
<table data-toggle="table"
>
<thead>
<tr>
<th data-field="fruit" data-sortable="true">Item</th>
<th data-field="date" data-sortable="true" data-sort-name="month">Date</th>
<th data-field="type" data-sortable="true">Type</th>
</tr>
</thead>
<tbody>
<tr><td>Pear </td><td data-month="1">January</td> <td>Fruit</td></tr>
<tr><td>Carrot</td><td data-month="3">March</td> <td>Vegetable</td></tr>
<tr><td>Apple </td><td data-month="2">February</td><td>Fruit</td></tr>
</tbody>
</table>
When I click the “Date” header, I want it to sort by the numerical data-month attribute (1, 2, 3) rather than the
Is this possible?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:19 (1 by maintainers)
Top Results From Across the Web
Adding data-order attribute value in <td> tag for custom ...
Try using .sort() method, and define your own sorting logic to sort the table rows as desired... developer.mozilla.org/en-US ...
Read more >Order by custom data attribute
I wanted to introduce a click event that would sort the table based on the data-paramX I am not sure if this is...
Read more >Bootstrap Table-Sort by custom data attribute
Test your JavaScript, CSS, HTML or CoffeeScript online with JSFiddle code editor.
Read more >How to sort HTML elements by data-attribute
In this article, we sort the unordered list elements using the data attribute with variable values on which the elements are to be...
Read more >custom-data-attribute - datatables - html - jquery - sorting
Html – Custom sorting on values in a data-sort attribute with Jquery Datatables · Best Solution · Related Solutions ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Aabling @zkan Were you able to figure out a workaround for this issue?
@wenzhixin Can you please answer Aabling and zkan? I have the same issue and cannot seem to find a solution.