Sorting off

Sorting off

yonasu3yonasu3 Posts: 3Questions: 0Answers: 0
edited June 2012 in General
Hey!

I was wondering if I can somehow set sorting off as third state for sorting.
For example, if user clicks header three times, the sorting states would be:

1. Asc
2. Desc
3. Off, use default sorting

I'm not sure if this is possible, but it would be nice to have that option.

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    What do you mean sorting off? Would the table revert to its load state or something like that? There is an API plug-in which will restore the sort ordering to the original load order: http://datatables.net/plug-ins/api#fnSortNeutral - you could potentially use that with fnSort to do what you are looking for.

    Allan
  • yonasu3yonasu3 Posts: 3Questions: 0Answers: 0
    Yes, that's exactly what I ment, sorry for being so unclear.

    Could fnSortNeutral be used with aoColumns somehow?

    [code]
    "aoColumns": [
    { "asSorting": [ "asc" ] },
    { "asSorting": [ "desc", "asc", fnSortNeutral ] },
    { "asSorting": [ "desc" ] }
    [/code]
    for example?
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    No - I'm afraid you would need to unbind the event handler DataTables added to the header elements, and then replace it with a custom event handler that would switch between using fnSort and fnSortNeutral as required.

    Allan
  • yonasu3yonasu3 Posts: 3Questions: 0Answers: 0
    Ok, thanks. I'll try that later.

    Thank you for your help.
This discussion has been closed.