How to update cell after rowReorder

How to update cell after rowReorder

cutigersfancutigersfan Posts: 4Questions: 2Answers: 0

I have some simple code to update a cell after click (actually mousedown). It all seems to work fine. I forked a jsfiddle to illustrate. Click on a row and you'll see the id column update. However, once rows are reordered the wrong row gets updated if you click below where you dropped the row. Drag #9 to #2 spot. Then click around some more and you'll see. Seems like the cell() and data() functions I'm using don't work well together.

See: https://jsfiddle.net/v7rt9sxb/3/

Answers

  • cutigersfancutigersfan Posts: 4Questions: 2Answers: 0

    Well, nobody answered. So I don't know correct way to do this or understand why. My work around was to create a hidden column to store the original index. I could then use that original index when calling table.cell(index,column). Maybe not so elegant, but works.

  • cutigersfancutigersfan Posts: 4Questions: 2Answers: 0

    Well, I figured out I was going at this all wrong. I shouldn't have been using the cell function to update the cell. Instead, update the data, invalidate, and draw.

    See https://jsfiddle.net/v7rt9sxb/4/

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Hi,

    Sorry I didn't manage to reply before, but you have the right of it now. cell().invalidate() is the way to tell DataTables that the data has changed.

    Allan

This discussion has been closed.