3

I am rendering a table thanks to jQuery datatable plugin .

When you allow sorting on a column , column is sorted if you click on title text or on arrow just near:

enter image description here

Do you know how to disable sorting for click on text but let sorting for click on arrows?

1
  • You need to add something like this: "bSortable": false, If you share the code you're using to render the table, I can show you exactly where it goes. Commented Apr 6, 2015 at 16:50

2 Answers 2

6

I had the same problem and I solve it this way (found the solution here: https://datatables.net/forums/discussion/27035/how-to-disable-sorting-click-event-on-table-header-children):

If you supose the checkbox has the ID #chkbx, this code should work:

$('#chkbx').click(function(event){

  //Your code here

  event.stopPropagation();
});

With the event.stopPropagation() prevent the sorting of the column.

Sign up to request clarification or add additional context in comments.

Comments

-1
$('#example').dataTable( {
      "aoColumnDefs": [
          { 'bSortable': false, 'aTargets': [ 1 ] }
       ]
});

1 is your column number (remember the first column is actually 0).

1 Comment

thank but i don't want to disable sorting, just disable sorting when i click on title text

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.