Row index and sorting

Row index and sorting

mikerileymikeriley Posts: 1Questions: 1Answers: 0

I'm using the TableTools extension for it's row selection functions, and want the up and down arrow keys to allow moving the selected row up and down.

I have this working by keeping track of the index of the currently selected row -- when you hit down, it increments the index and selects the next row, and vice versa.

But when I sort on one of the data columns, things break, because it seems DataTables is using the original row indexes of the data rather than the updated indexes after sorting.

For example:

tableapi.row(0) is always returning the first row as the table was originally displayed. I was expecting it would return the first row as the table is currently displayed. I've tried specifying the selector-modifier {order: 'current'}, but it doesn't seem to have any effect.

I'm not sure if I'm doing something wrong here, or if there's some other way to go about this -- I'm just looking to be able to access the row indexes as the rows are currently displayed in the table.

This discussion has been closed.