Updating existing row of datatable in a correct row position based on row_id
Updating existing row of datatable in a correct row position based on row_id
Hi there,
I know it seems like a duplicate question since quite a few people have asked the same one in the past. What I'm trying to do is to update a particular row in my datatable based its row id if it meets the condition in my document.addEventListener() function. I'm using these two lines of code below:
var d = table.row( #row_${index}
).data();
table.row().data(d).draw();
However, it did not write the update into the required existing row but overwrote the update to the first row instead... It picked up the correct row (by row_id) so I do not think there is anything wrong with the row_selector. How can I fix this behavior? Any help would be greatly appreciated! Thanks!
P/S: Of course, before thinking about updating one row at a time, what I had done is to re-render the whole table with the updated single row by updating the source data but it's very sluggish and inefficient as it sounds due to the latency of rendering process.
This question has an accepted answers - jump to answer
Answers
You still need to pass in a
row-selector
orrow()
will select the first row. Do this:Not sure I understand what you are trying to do. Please provide more details.. If you are looping rows and updating them don't use
draw()
. Use it separately after the loop is complete so it executes once.Kevin
Thank you Kevin