Is it possible to only update specific cells using ajax.reload() option?
Is it possible to only update specific cells using ajax.reload() option?
Hi,
I am using child row (showing extra information) format from the following example:
https://datatables.net/examples/api/row_details.html
I read the data using ajax method. Certain cells in the table continuously get updated, therefore I use
setInterval(function(){
table.ajax.reload(null, false)
}, 3000)
However, each time the entire table gets updated and this means every 3 seconds if I have expanded a row to read additional information goes back to its "less information" format which is quite frustrating.
I have already seen the answer to other questions that table.ajax.reload() only updates the entire table. So I would like to know if there is any way to reload the data for only specific cells?
Many Thanks
Dr Golnaz
This question has accepted answers - jump to:
Answers
This example shows how to keep the child rows open with
ajax.reload()
:http://live.datatables.net/qolevune/1/edit
You can create a jQuery Ajax to fetch the updated data. You can use
row().data()
orcell().data()
to updated existing table data or userows.add()
to add new rows to the table.Kevin
Thank you very much Kevin,
I wouldn't be able to do it without this example! Would you possibly be able to give an example on using cell().data()? It is a bit clear for me how to do it.
Also, is it possible for the same table to add or remove a row with the same approach?
Thanks again,
Dr Golnaz
See this example. It uses
row-selector
as a function to find the desiredrows().indexes()
that match the row(s) to update. It then usescell().data()
to update the Ashton Cox cell.http://live.datatables.net/xuvozaxu/1/edit
Use
row.add()
orrow().remove()
to add or remove a row. There are plural versions of these API's to affect multiple rows.Kevin
Many thanks Kevin.