Way to row.add() a row at the start without sorting?
Way to row.add() a row at the start without sorting?
MidaIganes
Posts: 11Questions: 5Answers: 0
in DataTables
Currently simply doing something like this will put the item as last in the list, ending up several pages deep.
tableTemp.row.add( data.tableRowInfo ).draw();
And unfortunately the data formatting used does not support any kind of a reasonable sort by column.
This discussion has been closed.
Replies
AFAIK you need to use
draw()
to show the added row which updates the table search and sorting.Some options that may help are to use the Absolute sorting plugin. Maybe you can use either the pageJumpTo() plugin or the row().show() plugins.
Kevin
Is there no way to have a prepend instead of append situation with this somewhere as it's updating the internal list?
When using
row.add()
Datatables will display the row based on the table's sorting which you understand. If no sorting is applied the data is displayed in the order it receives the data set.This example shows that
row.add()
appends the data to the end of the data set. It has ordering disabled so the order is that of the data.http://live.datatables.net/ruhakowi/1/edit
Datatables doesn't have a built-in mechanism to prepend the new rows.
One option might be to use a timestamp. Use a hidden column for the timestamp and sort descending on this column. You may need to generate a timestamp for the original data set. When using
row.add()
use Javascript to generate a timestamp for that row.Kevin