Abort sorting

Abort sorting

John ArcherJohn Archer Posts: 56Questions: 1Answers: 0
edited January 2012 in General
Hi there!

We want to gather certain information of the sorting event. So we bound the event like this to our datatable:

[code].bind('sort', function (a, b) {
}[/code]

Is there a way to _stop_ the actual sorting somewhere/in the sort event, so we can just use the information (which header was clicked, sort direction - even for mulitsort) but don't want DataTables to do the acutal sort (for now)?

Or is the only way to achieve this using the fnDrawCallback and stop drawing if we encountered that we sorted?

Thanks a lot!

Regards

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    I've got to admit that I've never tried this, but what you could do is use the fnPreDrawCallback method, which allows you to abort the draw, however the data will already have been sorted by the time you get to the draw, so this might leave the table in a slightly odd state until the next draw...

    With the callback function you could either use the oSettings.bSorted parameter, or set a flag using your sort event listener.

    The other option is it unbind the DataTables sort events and then add your own and call fnSort whenever you want the table to actually do the sort.

    Allan
  • John ArcherJohn Archer Posts: 56Questions: 1Answers: 0
    Hi Allan,

    ok, thanks a lot for all that useful information. We'll have a look into this.

    Regards!
This discussion has been closed.