Reputation: 445
I am looping through every row in my dataTable and I want to update one specific cell. I have the following code:
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
data[5] = "test";
table.draw();
} );
It looks like it is not updating the data[5] correctly or it doesn't know it is the data of this row.
In general, my target is to execute some ajax for each row and with the return value of my ajax I want to set the data[5] value.
What am I doing wrong?
Upvotes: 1
Views: 4481
Reputation: 58880
Use row().data()
API method to set the data for each row inside the loop.
table.rows().every( function ( rowIdx, tableLoop, rowLoop ) {
var data = this.data();
data[5] = "test";
this.row(rowIdx).data(data);
table.draw();
} );
See this jsFiddle for code and demonstration.
Upvotes: 3