FnRowCallback : targeting an element in a selected row

FnRowCallback : targeting an element in a selected row

ulrikeulrike Posts: 39Questions: 1Answers: 0
edited December 2012 in General
Hello,

I am trying to select multiple rows, by clicking on the row and also, if the user chooses to do so, by clicking on a checkbox, in the first column of my table.

This works fine if i do not use the FixedColumns plugin. But with the plugin enabled, after selecting some rows, switching pages, then coming back to the first page, the rows are still marked as selected, but the checkbox is unchecked. I can't seem to target it correctly.

I created a test case here (only the first five rows are selectable, i was too lazy to do more markup) : http://live.datatables.net/oyaseh/41/

I would be very grateful for some help.

Best regards.

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    The problem with using FixedColumns and live DOM elements such as checkboxes is that it clones the elements to be put into the fixed column - so it is completely detached from the original row - i.e. there is no reference between the the original row and the cloned element.

    At the moment what you would need to do is use fnDrawCallback rather than fnRowCallback and loop over all rows, syncing the fixed column with the master row. Very messy I know, but without cloning the rows I'm not sure how much of a better answer there can be, and cloning rows is baked quite deeply into FixedColumns.

    Sorry I don't have a better answer.

    Allan
  • ulrikeulrike Posts: 39Questions: 1Answers: 0
    Thank you Allan. I will try to work my way through this.. or just use a CSS-based hack if it gets too complicated :)
  • ulrikeulrike Posts: 39Questions: 1Answers: 0
    So in the end I use CSS to simulate an empty checkbox and a checked box when the row is selected. Works great.
This discussion has been closed.