Have a column ignore sorting

Have a column ignore sorting

isleshocky77isleshocky77 Posts: 4Questions: 0Answers: 0
edited November 2013 in General
I believe I've read through all of the examples, docs, and apis; and I still can't find how to do this or if it is possible at all. I need to be able to have one column completely ignore sorting.

The use-case for this to make it more clear what I'm trying to do is that the first column of my table is called rank which is a linear set of numbers. I would like when you sort any of the other columns that the first column containing the rank still say in the same order from 1 to X.

I've looked into possibly using mData, but it doesn't seem to have an index I can base it off of.

Thoughts?

JSFiddle: http://jsfiddle.net/isleshocky77/6MhZ6/

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    It sounds like you want aaSortingFixed I think? http://jsfiddle.net/6MhZ6/1/ ?

    Allan
  • isleshocky77isleshocky77 Posts: 4Questions: 0Answers: 0
    edited November 2013
    This option forces sorting to the first column and doesn't allow you to sort by any of the other columns. I want to allow sorting by the other columns, but have it not affect the first column (rank).

    Essentially think of the first column as another set of headers. I thought maybe giving them th instead of td would allow for this; but not so. Currently the only thing I can think to do would be to put another table next to the table with datatable with just the column; however, I don't believe that is a good solution.
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Oh I see! Like this: http://datatables.net/release-datatables/examples/api/counter_column.html ?

    Allan
  • isleshocky77isleshocky77 Posts: 4Questions: 0Answers: 0
    Exactly like that! Thanks. I skipped over this function originally because I was thinking that it only drew the first time. Thanks again.
  • isleshocky77isleshocky77 Posts: 4Questions: 0Answers: 0
    I'm not sure how close you are to the development team, or if you are part of it (having a hard time tracking down a bug tracker or an about page); however, there is a bug on that page you posted. The referenced example code on the bottom of the page is actually different than the code running the page. It's missing the following statement (which makes the code unusable).

    [code]
    var that = this;
    [/code]
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    > I'm not sure how close you are to the development team

    Heh - I am the "development team" :-)

    Thanks for pointing out the error on the page. I've just corrected it.

    The example has been rewritten for DataTables 1.10, which I think now uses a more elegant solution: https://github.com/DataTables/DataTables/blob/1_10_wip/examples/api/counter_columns.html#L31

    Allan
This discussion has been closed.