Is it Possible to Sort Only by Clicking the Sorting Arrows

Is it Possible to Sort Only by Clicking the Sorting Arrows

SewellSewell Posts: 2Questions: 0Answers: 0
edited September 2012 in General
Hi,

First of all - great application!

My problem is that one of my columns is a checkbox column that has a checkbox to "check all" in the heading. I would still like to be able to sort this column, but I don't want it sorting the column every time the "check all" checkbox is checked/unchecked. Is it possible to set the table so that the only way to sort columns is by clicking only the sorting arrows, and not by clicking anywhere in the heading?

Thanks,
Will

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    > but I don't want it sorting the column every time the "check all" checkbox is checked/unchecked

    You could have the jQUery event cancel the bubble (stopPropagation()) which might work for you?

    Or you can unbind the event listeners DataTables added to the column headers and use fnSortListener to attach listeners to custom elements (i.e. a div inside the header and you put there).

    Allan
  • SewellSewell Posts: 2Questions: 0Answers: 0
    Thanks for the advice! I'll have a look into those options. By the way, how do I unbind the event listeners? I've never used jQuery/JS before now.
  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    http://api.jquery.com/unbind/ or http://api.jquery.com/off/ (better if you are using jQuery 1.8+)

    Allan
This discussion has been closed.