How to add a row with HTML5 data-order attribute?
How to add a row with HTML5 data-order attribute?
hansoli
Posts: 1Questions: 1Answers: 0
https://datatables.net/manual/data/orthogonal-data
This page says it should pass data with "@data-order" but it seems not working for me.
<table id="dataTable">
<thead>
<tr>
<th>Name</th>
<th>B</th>
<th>C</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td data-order="1">First</td>
<td>3</td>
</tr>
<tr>
<td>Doe</td>
<td data-order="0">Second</td>
<td>4</td>
</tr>
</tbody>
</table>
$(document).ready( function () {
var table = $('#dataTable').DataTable();
table.clear();
table.row.add({"0": "John", "1":{"display":"First2", "@data-order":"1"}, "2": "3"})
table.row.add({"0": "Doe", "1":{"display":"Second2", "@data-order":"0"}, "2": "4"})
table.draw();
} );
- Expected: Second column display values with data-order attribute.
- Actual: Second column has no contents. Of course, there is no data-order, too.
Fiddle: https://jsfiddle.net/zLp89m3j/1/
How to fix it?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I fear that you've hit a bug in DataTables that I wasn't aware of there. I've committed a fix and test for it, so it will be fixed in the nightly version shortly, and I think we'll do a 1.10.20 release of DataTables in February which will carry the fix.
Thanks for letting me know about that and the test case!
Allan