Disable Sorting when Checkbox in Column Header is Checked/Unchecked

Disable Sorting when Checkbox in Column Header is Checked/Unchecked

tcbeatontcbeaton Posts: 16Questions: 0Answers: 0
edited November 2013 in DataTables 1.9
I previously posted this, had a work-around, but the client would like the checkboxes in the header.

I have added a check box in the header to show/hide additional columns of the table. When the check box is clicked, the column is sorted; is there any way to disable the sorting of the column if the checkbox is changed, but to still sort if the text is clicked (normal operation)?

I've tried placing "return false" in the onClick (as shown below), but the sort appears to happen prior to the onClick. Using "bsort:false" is not an option, since it would disable sorting of the column all together.

Thanks for the help.

[code]

Core POP



[/code]

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    You could add stopPropagation in a 'click' event handler for your checkbox (a DOM0 event probably isn't enough here - you'll need to use a jQuery or DOM event handler).

    Allan
This discussion has been closed.