Not disabling the first th column

Not disabling the first th column

xtremer360xtremer360 Posts: 84Questions: 2Answers: 0

I'm trying to figure out why its not disabling the first column. Anyone know?

http://jsfiddle.net/ztku7zzd/1/

This question has an accepted answers - jump to answer

Answers

  • xtremer360xtremer360 Posts: 84Questions: 2Answers: 0

    Any ideas on this?

  • xtremer360xtremer360 Posts: 84Questions: 2Answers: 0

    I am clueless to why this is happening,

  • xtremer360xtremer360 Posts: 84Questions: 2Answers: 0

    I'm trying to figure out why the first column is allowing for sorting when I gave the datatables modification to not be sortable. What am I doing wrong? I'm trying to get the first table heading to NOT be sortable.

    $(document).ready(function(){
    $('#basicTable').DataTable({
    "aoColumnDefs": [
    { "bSortable": false, "aTargets": [ "nosortable" ] }
    ]
    });
    });

    http://jsfiddle.net/xtremer360/uwe4mp0d/

  • john_ljohn_l Posts: 45Questions: 0Answers: 12
    Answer ✓

    As answered on StackOverflow:

    aTargets should be an array of the column numbers you want the definition to apply to:

    http://jsfiddle.net/uwe4mp0d/1/

    $(document).ready(function(){
    $('#basicTable').DataTable({
    "aoColumnDefs": [
    { "bSortable": false, "aTargets": [ 0, 3 ] }
    ]
    });
    });

  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin
    edited November 2014

    As the documentation for columns.orderable notes that flag indicates only that the end user cannot sort the table using it. You can use order() to order the table by the column for example.

    As such, the default order of [[0, 'desc']] is being applied. Simply add order: [] to the init for your table if you don't want a default order applied at all (using order).

    I'll add a note to the documentation to state this explicitly.

    Allan

  • allanallan Posts: 61,765Questions: 1Answers: 10,111 Site admin

    aTargets should be an array of the column numbers you want the definition to apply to

    Actually the columnDefs.targets can be a string as well to target columns with that class, which it looks like what @xtremer360 is doing.

    Allan

  • john_ljohn_l Posts: 45Questions: 0Answers: 12

    Ah, I didn't realize you could use a class for the target - thanks.

    Looks like Allan has also already covered the update in stackoverflow with a new default order so you should be good to go now: http://jsfiddle.net/uwe4mp0d/2/

This discussion has been closed.