Checkbox Column
Checkbox Column
Thorlax402
Posts: 2Questions: 0Answers: 0
Hello,
So I've been trying to figure out how to get a checkbox column working with DataTables all day. My issue is not with the display of them, but with making the checkbox located in "" to toggle all the other checkboxes on and off. I normally have no issue making a jquery function to check all the other boxes, but my normal way of doing it seems to conflict with datatables reloading. For example, when I click on the checkbox in it toggles all the others for a millisecond before the table is reloaded. My initial idea for fixing this was to put a "return false;" line in my click function. This would check all other other boxes just fine, but would not check the box inside of . Since this box can't be checked then it more acts as a "check all" box than a "toggle all" box.
Does anyone have any suggestions for making this work?
Thanks.
So I've been trying to figure out how to get a checkbox column working with DataTables all day. My issue is not with the display of them, but with making the checkbox located in "" to toggle all the other checkboxes on and off. I normally have no issue making a jquery function to check all the other boxes, but my normal way of doing it seems to conflict with datatables reloading. For example, when I click on the checkbox in it toggles all the others for a millisecond before the table is reloaded. My initial idea for fixing this was to put a "return false;" line in my click function. This would check all other other boxes just fine, but would not check the box inside of . Since this box can't be checked then it more acts as a "check all" box than a "toggle all" box.
Does anyone have any suggestions for making this work?
Thanks.
This discussion has been closed.
Replies
Thanks.
[code]
table.$('input', {"filter": "applied"}).prop("checked", true);
[/code]
What that is doing is a jQuery selector on all TR elements in the table with the applied filter, and then performing the jQuery action - in this case checking the checkboxes.
With 1.8 and below, you need to use the plug-in API method fnGetFilteredNodes: http://datatables.net/plug-ins/api#fnGetFilteredNodes . That will get all TR elements, which you can then loop over and do the jQuery thing again. However, 1.9 is lovely for this kind of thing ;-)
Final beta should be available very soon, and the final release about a week after that.
Allan