Adding rows with data-order
Adding rows with data-order
I'm using:
$dataTable.row.add($("<tr><td data-order="1">someformatting 1</td></tr>")[0]);
to add a bunch of rows to a table, basically the someformatting can contain some type of CSS formatting and span's, icons, and things, but the data-order doesn't seem to work correctly.
If I pull the actual table out and put it in jsfiddle the sorting works fine so I assume it has to do with the rows being added one at a time.
This question has an accepted answers - jump to answer
Answers
I'll need to look into that - that should have worked. Thanks for letting me know.
Another option is to add the data using an object, rather than a Node. See this section of the API for details.
Allan
A few things:
data-orderin the row during initialization to start using it. Ifdata-orderis not in the HTML table when initialized then normal ordering of the data in the column will be used. In other words if you are usingrow.add()with an empty table thendata-orderwon't be used. See the HTML5 orthogonal data docs for more details.draw()to have Datatables resort the table after usingrow.add().Also note the added
draw(). Here is a running example with your code snippet:https://live.datatables.net/fabosexi/1/edit
If you still need help then please provide a test case showing the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin