Troubles Updating Rows Dynamically
Troubles Updating Rows Dynamically

I am currently trying to Update Rows Dynamically.
**What I tried: **
This only updates One of the rows.
jQuery.each(newDATA, function () {
table.row().data(this).draw();
});
This updates only have the rows
jQuery.each(newDATA, function () {
table.row().data(this);
});
table.draw()
I also tried this but it only updates one row
jQuery.each(newDATA, function () {
table.row().data(this).invalidate();
});
table.draw()
Any Ideas
This question has an accepted answers - jump to answer
Answers
You're using
row()
, if you want to update more than one userows()
,Colin
I tried that as well.
table.rows().data(NewData).draw();
No updates are occuring. I see that the columns are being rerendered by checking my chrome console and I can verify that the Json data returned is the correct data. Any other advice?
I also tried the following with now success:
EDITIED
According to the
rows().data()
docs you can only get the row data:My guess is you aren't passing into
row()
therow-selector
of the row you want to update. If you don't use a selector then the first row will be the only row updated which may be why you aren't seeing the updated as expected. You can see this in this example:http://live.datatables.net/demurupu/1/edit
Select a row (not Tiger Nixon) then click the
Update with selector
button. The selected ro will be updated. Now click the UpdateUpdate without selector
button and Tiger will be updated.Kevin
@kthorngren you were correct. I needed to pass a row-selector. When I tried it in the past it didn't work because I was missing the pound sign. The following code in my loop did the trick. This was due to the fact that I was using a custom rowid.
table.row("#" + this.ID).data(this)
Also, if rows() is only a getter and not a setter I'm wondering why colin recommended it. He must know something we don't. Maybe the documentation is wrong?
Ha, no, I definitely don't know something Kevin doesn't
It was early in the morning, and the coffee hadn't kicked in. Apologies for the confusion.
Colin