Disabling one column "sort" feature

Disabling one column "sort" feature

zscallyzscally Posts: 7Questions: 0Answers: 0
edited March 2009 in General
Hello,

Im a noob to ajax but love you data table project F'in brilliant!@!@!

anyways I was wondering if is possible to disable sorting on just one column...

say I want to show the edit / Delete buttons within one of the tables I dont want to sort this column

Thank you

Zach

Replies

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Hi Zach,

    Thanks for the kind words! It certainly is possible to disable sorting on just one column - what you are looking for is the 'bSortable' parameter: http://datatables.net/usage#bSortable

    Have a look at this example: http://datatables.net/examples/example_hidden_columns.html - although it doesn't use the bSortable parameter itself - you'll see the basic usage for this family of parameter.

    Hope this does the trick for you.

    Regards,
    Allan
  • zscallyzscally Posts: 7Questions: 0Answers: 0
    Hey Allan,

    Thanks a bunch man.
  • zscallyzscally Posts: 7Questions: 0Answers: 0
    Hmm must have just one char off some getting it right lol

    $(document).ready(function() {
    $('#example').dataTable( {
    "aoColumns": [
    /* ID */ null,
    /* Type */ null,
    /* Make */ null,
    /* Model */ null,
    /* Year */ null,
    /* Size */ null,
    /* Fuel */ null,
    /* Color */ null,
    /* MSRP */ null,
    /* Price */ null,
    /* Milage */ null,
    /* Active */ null,
    /* Clearance Item */ null,
    /* Date */ null,
    /* Links */ { "bSort": false,
    "bVisible": true },
    ] } );
    } );


    anyidea what im doing wrong?
  • zscallyzscally Posts: 7Questions: 0Answers: 0
    Hmm I think i Got it with "bSortable" insted of bSort cool@!!
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Yup - sorted ;-)

    I might implement a checker in future version which give some kind of warning when unknown parameters are passed in...

    Allan
  • mimicmimic Posts: 43Questions: 0Answers: 0
    In this case please do it as an option. Because it is quite handy to be able to use only one object to store all info about your table if you use this info in different parts of the code where dataTables is only one part and so you have there also some other, additional, data.
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Hi mimic,

    Yes indeed - I see your point. It would probably log a warning to console or something like that, rather than making it a critical failure. Just something to help developers spot an issue like this quick.

    Allan
  • gercheqgercheq Posts: 1Questions: 0Answers: 0
    what if my tables are being generated dynamically and I want to disable sorting only on the first element?
  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Hi gercheq,

    bSortable is still the option you want. If you set that for your first column, then sorting will be disabled for that column, regardless of the data source.

    Regards,
    Allan
This discussion has been closed.