HI WELCOME TO KANSIRIS

jQuery DataTables how to disable sorting when clicking on table header?

Leave a Comment

SOLUTION

Use order option to define initial sorting along with columnDefs.orderable set to false to disable sorting for specific columns and columnDefs.targets set to _all to target all columns.

var table = $('#example').DataTable({
   order: [[2, 'asc']],
   columnDefs: [{
      targets: "_all",
      orderable: false
   }]
});

If you don't want the sorted column to be higlighted use the following classes for your table: stripe hover row-border, see the HTML example below:

<table id="example" class="stripe hover row-border" cellspacing="0" width="100%">

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.