Get row number in display order after sort?
Get row number in display order after sort?
DataTables 1.10.5, Editor 1.4
JavaScript array is the data source. Using inline editing.
The values change programatically in the column that the table is ordered by. The table sort works just fine.
The issue I need to resolve is how do I get the new row number after a sort by its display order? That is, I want selectedRow
below to contain the row number as the user would see it. Currently, selectedRow
is set to the original display row location. (Also note, the JavaScript data is maintained in the same display order and rows().invalidate()
has been called, though I assume that is not necessary.) Also, using the modifier parameter did not change the result.
// toggle the row selection - note if not using Bootstrap, then class has to be '.selected'
$('#TVM tbody').on('click', 'tr', function () {
...
selectedRow = table.row(this).index();
// selectedRow = table.row(this, {order: 'index'}).index();
Thank you.
This question has an accepted answers - jump to answer
Answers
Use
cells().render()
to have DataTables return the rendered data.Allan
Hi Allan,
Thanks for the prompt reply. Unfortunately,
cells().render()
does not allow me to get what I need, unless I've coded it wrong.I want the row number after a sort, that is, the row number in display order.
Here is how I coded it.
selectedRow
after both assignments contains the same value. The original row number before the sort.Did I misinterpret your meaning?
Oh I see, I completely misunderstood and the
render()
method won't really help you in that case.Try:
Allan
That's what I need. Thank you.