Optimize updating multiple rows by rowId

Optimize updating multiple rows by rowId

TablefakTablefak Posts: 35Questions: 8Answers: 0
edited June 1 in Free community support

I wrote a code to update data in multiple rows using the rowId as selector. Is there a way to optimize this code for speed?

changedData.forEach(i => {
    table.row("#" + i).data(i)
})
table.draw()

I'm thinking I should not redraw the whole table but only the changed rows. However, I'm not sure how to do that in the most efficient way using the datatables api.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,188Questions: 26Answers: 4,925
    Answer ✓

    Calling draw() will apply sorting and searching to the table based on the changes made. Calling it once after the loop is about as efficient as you will get.

    Kevin

  • TablefakTablefak Posts: 35Questions: 8Answers: 0

    Thanks!

Sign In or Register to comment.