Problem with selected rows + stateSave + table.ajax.reload + removed data
flowerpower opened this issue · 2 comments
flowerpower commented
This is the problem:
I have a dataTable with some rows loaded with ajax from database, I use the table.ajax.reload function (for reloading data every 10 seconds) and the stateSave (for keep selected rows after every reload of data).
- I select 3 rows and the selected row counter on the table footer correctly say: "3 rows selected".
- I remove from database one of the selected rows.
- The table.ajax.reload function runs and reloads the data on the table and now there are a lower number of rows.
- Now the remaining visible selected rows is correctly 2 (because one is been removed from database) but the rows counter on the footer of the table count a wrong number! The counter say again "3 rows selected" !!!
How can I solve this problem?
haromy commented
is it server side ajax ?
dont use stateSave
,
add option serverSide: true,
flowerpower commented
I have solved the problem. The magic tip is to use the rowId option!!
In my example the rowId value is wrong, I need to use a unique json item returned from the ajax call. In my case:
for example:
rowId: 'Collocation'
where Collocation is an item of my json.