How can I re-do highlighting after re-adding and re-drawing data?

How can I re-do highlighting after re-adding and re-drawing data?

fbasfbas Posts: 1,094Questions: 4Answers: 0

I am using a local array as my data source, but occassionally refreshing that data and doing a clear(), rows.add(), and draw()

similar to : https://datatables.net/forums/discussion/comment/84307/#Comment_84307

I've also used the css/on-click method to highlight rows (multiple)

similar to: https://datatables.net/forums/discussion/comment/69331/#Comment_69331

understandably, when I refresh the data, and re-draw, I lose the highlighting on the rows. What would you recommend I do to preserve, or re-apply the highlighting on rows?

Is there a better (i.e. more data-centric, as opposed to dom-centric) way to trigger the highlighting? or would it be easier to poll the 'selected' rows in query before redrawing, then reapply the class after the re-draw?

thanks,

fb

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,178Questions: 26Answers: 4,923
    Answer ✓

    Here are a couple of options you can look at:
    createdRow
    rowCallback

    Kevin

  • fbasfbas Posts: 1,094Questions: 4Answers: 0

    thanks @kthorngren I use the createdRow call back, after caching the desired values in $('#datatable').dataTable().api().rows('.selected').data()

This discussion has been closed.