Multiple checkboxes in a row
Multiple checkboxes in a row
Good morning (o;
Set up a simple table where I display a list of suppliers with different states, like being active, showing on frontpage and use it in statistics.
I followed this example to be able to update the state when just toggling the checkboxes:
https://editor.datatables.net/examples/api/checkbox.html
Only problem (so far ;o) is that I can't set the checked set on each checkbox individually as per example as it handles only one per row:
rowCallback: function ( row, data ) {
// Set the checked state of the checkbox in the table
$('input.editor-active', row).prop( 'checked', data.Aktiv == 1 );
}
With this callback all checkboxes have the same state as the selector applies to all checkboxes per row.
thanks in advance
richard
Answers
Okay..seems I have to use a different class per checkbox...this seems to work:
And also needs individual editor updates per checkbox:
Maybe there is a shorter version?
Also don't know why the POST sends an empty string for inactive checkboxes....only 1 for active ones.
Yup - exactly that, otherwise the selector that sets the states wouldn't be able to tell the difference between the checkboxes!
You could possibly put your code into a function call like this:
Where
checkbox
would basically replicate those lines, but using the passed in variables.Allan