Dynamically Add and Remove old
Dynamically Add and Remove old

Hi,
I want to add rows dynamically and remove old by keeping latest 10 records only. I am pushing new rows every second, so I want to remove old rows.
Is there any API function that can keep X number of rows and remove rest?
This discussion has been closed.
Answers
No, but you can remove rows with
rows().remove()
- you would just need to determine which rows you want removed.Colin
can i use number of row to remove it?
for example: row(12).remove()
There are lots of selectors you can use to choose the rows to delete. These are documented in the
row-selector
docs. One way to do this is to userows().indexes()
, along withtoArray()
, to get the indexes of all the rows. Then slice() the array to get the rows to remove. Remove the rows then add the new. Here is a simple example:http://live.datatables.net/rogalazi/1/edit
I used
order
to run off ordering. You do not need to do this.Kevin