Updating individual cells in a row
Updating individual cells in a row
ChrisDennis
Posts: 12Questions: 5Answers: 0
I can't work how to update just the changed cells in a row.
I can get the relevant row like this:
let row = this.dt1.row('#row-' + data.id);
and then update the whole row successfully with
row.data(data).draw(true);
But since a change to the backend, data now only has changed values, so I want to iterate through all the cells in the row, and update the cells for which there is new data.
I tried this
row.cells().every(function () { ... }
but that function is fired for every visible cell in table, not just the one row.
What should I do?
`
This question has an accepted answers - jump to answer
Answers
The
cell-selectorcan be used to select a specific cell. If you know the specific row and column you could do something like this:Kevin
Thanks Kevin -- that partly solves the problem, and got me thinking on the right path.
I didn't emphasise in my question that I want to iterate across the columns and check which have data to update.
With a bit of help from Stackoverflow I eventually ended up with this, which relies on the properties of my
msghaving the same names as thedataentries in the table's column definitions. (Thecolumnsarray also has thenameof each column, so it could use those for matching if required.)