Issue with row index function

Issue with row index function

NishiNishi Posts: 1Questions: 1Answers: 0

When using row index function using the following syntax
$( '#table' ).dataTable().api().row('.selected',{ order: 'applied' }).index()
it returns the index of the row with original order and not current sort order.
Is this a bug?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @Nishi ,

    No it's not. row().index() returns the row index, which is constant regardless of the ordering or filtering. If you want to know the position of the selected row in the table, you can do something like this:

    table.rows().indexes().indexOf(table.row('.selected').index())
    

    Cheers,

    Colin

This discussion has been closed.