I've been trying to sort a checkbox field in DataTables jQuery plugin to check and uncheck.
I'm creating the input (checkbox) inside the table like this:
'<input type="checkbox" '+ check +' />'
check is containing the text "checked" or "".
So far I tried just to add DOM checkbox type of sort, like this:
{ "sSortDataType": "dom-checkbox" }
When I use the entire code from the plugin's API documentation, I get the following error:
Uncaught TypeError: Cannot read property 'afnSortData' of undefined inside my console.
Problem: pressing on the column header won't sort the column by checked or unchecked checkboxes.
I would like to get suggestions how to fix the above mentioned error or another way to sort using only jQuery and plugin's methods.
Thanks.
Just tried with a fixed code - no error. But sorting is messed up: it's just replacing with each other but not sorting. For example: if I have 1 checkbox checked and 9 not, the checked checkbox is switching from the third place to the sixth and again to the third and so on.
what i did is creatinga bool var in hidden P so it will be in the sameplace as the checkbox.than i disabled the option of change value in checkbox and the sorting is now working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With