Sorted by default + not clickable columns

Sorted by default + not clickable columns

RicardRicard Posts: 8Questions: 0Answers: 0
edited June 2011 in General
Hi Allan,

I'm confused about if my needing is possible.

I'm using "aaSortingFixed": [[ 3, "desc" ]], because I want to have my rows initially ordered by default.
I don't want that users could resort my datatable, that's why I'm using aaSortingFixed.

I'm confused in following point:
I don't understand why users can click on any column header.
I understand that I'm using aaSortingFixed because i don't want to allow users to click on headers.

Is there any way to have the datatables sorted by default (like using aaSortingFixed) and don't allow the users to click on column headers (like using bSort:false) ?

Thanks for this enjoyable plug-in.
Ricard

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    aaSortingFixed and aaSorting (the user sorting) get concatenated together to make the full sorting. So aaSortingFixed gets priority, but the user can still 'add on' more sorting columns.

    If you don't want to allow the user to do any sorting you can simply unbind the click event handler from the TH elements once the table has been initialised:

    [code]
    $('#example thead th').unbind('click');
    [/code]

    An alternative is to set all columns to "bSortable": false - that will stop the click event handler being added to the table.

    [code]
    "aoColumnDefs": [ { "bSortable": false, "aTargets": [ "_all" ] } ]
    [/code]

    That this latter one can be done could almost be considered a bug... but useful here :-)

    Allan
  • RicardRicard Posts: 8Questions: 0Answers: 0
    Thanks Allan,

    First option (to unbind the click event handler) it's perfect for my case.

    Thanks for your help
    Ricard
This discussion has been closed.