Re: [jQuery] how to get current sort order from tablesorter plugin?

2009-12-28 Thread vcohen

Thanks!

Someone on StackOverflow pointed out that current sort order is indicated by
the class applied to the column. So, I can test for the class
('headerSortUp', 'headerSortDown') on the Category column, and then trigger
a sort in the opposite direction. I think I'll do that rather then go after
an internal data structure that's not officially exposed thru an API. Thanks
for the info, tho!

- Val


aquaone wrote:
> 
> I believe tablesorter's internal sort is stored under "config.sortList"
> for
> the table DOM element. It's a multidimensional array of column indices and
> sort direction, e.g. [[2,0][0,1]].
> 
> aquaone
> 
> 

-- 
View this message in context: 
http://old.nabble.com/how-to-get-current-sort-order-from-tablesorter-plugin--tp26908861s27240p26945440.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.



Re: [jQuery] how to get current sort order from tablesorter plugin?

2009-12-23 Thread aquaone
I believe tablesorter's internal sort is stored under "config.sortList" for
the table DOM element. It's a multidimensional array of column indices and
sort direction, e.g. [[2,0][0,1]].

aquaone


On Wed, Dec 23, 2009 at 15:46, vcohen  wrote:

>
> I'm just starting to use Christian Bach's excellent TableSorter plugin, and
> I
> need to get a column's current sort direction. I have several columns:
>
> ID
> Name
> Category
>
> ID and Name are set to non-sortable using
> headers:{ 0: {sorter: false}, 1: {sorter: false} }
>
> I'm adding a click handler on Name so that it fires the sort event on the
> Category column. Using the example "Sort table using a link outside the
> table" (http://tablesorter.com/docs/example-trigger-sort.html), I'm able
> to
> get the Name header to fire the Category sort -- but it's hard-coded to
> sort
> in one direction.
>
> How can I get it to look at the current direction the Category column is
> currently sorted, and sort in the opposite direction? (I can handle
> flipping
> the values; since the sort order is 0 or 1, I can XOR the value to get the
> opposite, like var sort; sort ^= sort; -- my question is how to get the
> current value.
>
> Here's the code that currently sets the click handler on the Name column:
>
> $("#nameCol").click(function() {
>var sorting = [[2, 0]]; /* sort 3rd col (Category) descending */
>$("#SearchResults").trigger("sorton", [sorting] );  /* SearchResults is
> the ID of the soertable table */
>return false;   /* cancel default link action on a#nameCol
> */
> });
>
>
> Cross-posting this to StackOverflow, as well...
>
> Thanks!
>
> - Val
> --
> View this message in context:
> http://old.nabble.com/how-to-get-current-sort-order-from-tablesorter-plugin--tp26908861s27240p26908861.html
> Sent from the jQuery General Discussion mailing list archive at Nabble.com.
>
>