How to update a cell without refreshing the row?
How to update a cell without refreshing the row?
Hello, I have a DataTable with a refresh timer which is in charge do get a JSON and update some cells in my table.
I'm using a drawCallback to get the visible rows:
drawCallback: function (
let api = this.api();
currentRows = api.rows({page: 'current'});
startSync();
}
My method startSync has an ajax to request the new JSON and after complete de load, it calls my refreshRows method:
function refreshRows (data) {
currentRows.every(function () {
let i = 0, found = false;
while(i < data.length && !found) {
if(this.data().importId === data[i].importId)
found = true;
else
i++;
}
this.data(data[i]);
});
}
My problem is that its refreshing the whole row when I add the information to the data.
I have a checkbox selected for example and after this refresh, since the whole row is updated, the checkbox become unchecked.
What can I do to just update a cell which was modified??
Answers
The
cell().data()
method can be used to update just an individual cell. The problem at the moment is that when you userow().data()
it invalidates the whole row.cell().data()
will invalidate only the cell in question.Allan