1

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.