Get last row
Get last row
norey
Posts: 2Questions: 1Answers: 0
How can I get the last row ? I am on v 1.10.11
I thought the rows().indexes() might return an integer array and I can just get the last item, but that wasn't the case. So any hints?
This discussion has been closed.
Answers
Use the
selector-modifier
options to tell DataTables what order to give you the data in - for exampletable.rows( { order: 'applied' } ).indexes()
and you can take the last row from that array.If you just want to get the last row immediately use the
:last
selector for therow-selector
- i.e.:table.row( ':last', { order: 'applied' } )
.Example: http://live.datatables.net/zurisoxe/1/edit
Regards,
Allan
Thanks.
What I'm trying to do is get the last row of a table, edit each item to replace a name/id with the same value and an incremented counter.
My question, is how can I edit each last_row[i] ? how can I use selectors on e.g. last_row[0] and fetch/edit some attributes? is there something in datatables that can make it faster?
Thanks
I'm afraid I'm not quite understanding. In the above code you are using
row.add()
to add a new row. If you want to update the data in an existing row userow().data()
(which can be used as both a getter and setter).Allan