Adding data-order to dynamically loaded content
Adding data-order to dynamically loaded content
kiwis
Posts: 15Questions: 10Answers: 0
in DataTables
I'm adding new rows to my datatable va rows.add() while looping through a JSON array.
One of the columns is "firstname lastname" as a full string but I want to sort by lastname only. Hence using the data-order option.
Is it possible to add this in somehow?
This discussion has been closed.
Answers
You can use orthogonal data for that. In
columns.render
, you can return a different value for the ordering. If you're using HTML5 tags, likedata-order
, that should happen automatically, see example here: https://datatables.net/examples/advanced_init/html5-data-attributes.htmlColin
Here's what I have. My two date columns sort perfectly. My first name column doesn't.
On a click even I'm loading content via fetch and row.add
Finally my template
I'm removed other columns but 7 & 8 need sorting like the first (0).
Can you link to a test case showing the issue (as noted in the forum rules), so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Allan