javascriptjquerytablesorter

Cancel sort if certain conditions are met


I'm using jquery plugin tablesorter and I'm stuck with the following situation: my grid allow inline edition and if edition is active I want to disallow users to sort columns since this causes troubles.

How can I disallow sorting under certain conditions? I thought event sortStart would help me but I have no mechanism in there to cancel the sort.


Solution

  • Without enough information about your problem, I can say the safest way to go would be to define a flag variable (boolean) which will be set to true when inline editing is in progress, and set to false when editing is finished. Then, you could recode your sorting event to return false if your flag variable is true.

    UPDATE

    Here is the solution: http://tablesorter.com/docs/example-options-headers.html. You can disable sorting using the code from this example.