Join the Stack Overflow Community
Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

I have a question regarding jQuery DataTables.I have the following situation , when table is loading everything should be sorted by third column , but at the same time , I sorting by columns should be disabled (when clicking on the header of the table), and highlighting of column on which sorting is done should be also disabled.

Please if you have any idea , share it with me. Thank You.

share|improve this question
    
a quick google search turns up lots of results for this – charlietfl Jan 25 at 19:29
up vote 1 down vote accepted

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%">

DEMO

See this jsFiddle for code and demonstration.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.