Is it possible to only update specific cells using ajax.reload() option?

Is it possible to only update specific cells using ajax.reload() option?

GolnazGolnaz Posts: 23Questions: 5Answers: 0

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

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765
    Answer ✓

    if I have expanded a row to read additional information goes back to its "less information" format which is quite frustrating.

    This example shows how to keep the child rows open with ajax.reload():
    http://live.datatables.net/qolevune/1/edit

    So I would like to know if there is any way to reload the data for only specific cells?

    You can create a jQuery Ajax to fetch the updated data. You can use row().data() or cell().data() to updated existing table data or use rows.add() to add new rows to the table.

    Kevin

  • GolnazGolnaz Posts: 23Questions: 5Answers: 0

    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

  • kthorngrenkthorngren Posts: 20,269Questions: 26Answers: 4,765
    Answer ✓

    Would you possibly be able to give an example on using cell().data()?

    See this example. It uses row-selector as a function to find the desired rows().indexes() that match the row(s) to update. It then uses cell().data() to update the Ashton Cox cell.
    http://live.datatables.net/xuvozaxu/1/edit

    Also, is it possible for the same table to add or remove a row with the same approach?

    Use row.add() or row().remove() to add or remove a row. There are plural versions of these API's to affect multiple rows.

    Kevin

  • GolnazGolnaz Posts: 23Questions: 5Answers: 0

    Many thanks Kevin.

This discussion has been closed.