Reputation: 5601
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:
Do you know how to disable sorting for click on text but let sorting for click on arrows?
Upvotes: 3
Views: 2641
Reputation: 165
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.
Upvotes: 6
Reputation: 4323
$('#example').dataTable( {
"aoColumnDefs": [
{ 'bSortable': false, 'aTargets': [ 1 ] }
]
});
1 is your column number (remember the first column is actually 0).
Upvotes: -1