1

I have 6 columns in my jQuery Data table and want to disable sorting for the first and last column.

I have used the following code:

$('#UserDetails').dataTable({
    "aoColumns": [
          { "bSortable": false },
          null,
          null,
          null,
          null,
          { "bSortable": false }
      ]
});

This code disables sorting for the last column but not the first.

Can someone please help?

1
  • Can you create a jsfiddle which reproduces the problem? I am not able to -> jsfiddle.net/fw0z7sc3 What version of dataTables are you using? Commented Dec 3, 2014 at 11:57

3 Answers 3

3

For 1.10.13, you can use the following

$('#UserDetails').dataTable({
    "columnDefs": [
        {
            orderable: false,
            targets: [0,5]
        }
    ]
);
Sign up to request clarification or add additional context in comments.

Comments

2

try this

$('#UserDetails').dataTable( {
      "aoColumnDefs": [
          { 'bSortable': false, 'aTargets': [ 0,5 ] }
       ]
});

where 0,5 are the indexes of the columns that you want to exlude from the sort

2 Comments

Still the same issue continues. The 6th column becomes unsortable but first column still sorts
can you reproduce it on a fiddle so I can see it?
1

In Jquery datatable usually we use last column for sending extrdata/payload so if you have 6 visible columns actually they are 7 columns so:

$('#UserDetails').dataTable({
    "aoColumns": [
          { "bSortable": false },
          {"bSortable": true},
          {"bSortable": true},
          {"bSortable": true},  
          {"bSortable": true},
          {"bSortable": false}, 
          {"bSortable": false, "bVisible":false} //invisible column
      ]
});

1 Comment

Generates error that there is no 6th column defined. So I added a new column but still same problem continues..

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.