views:

126

answers:

1

I am using jquery table sorter and have two tables. Instead of sorting the data just in the first table, could there be a way to combine the data in the second table and sort both?

As an example, sorting column 1 on table 1 OR 2, will result in:

//ORIGINAL        //RESULT
TABLE 1           TABLE 1
col1 | col2       col1 | col2
1    | 1          1    | 1
3    | 3          2    | 2
5    | 5          3    | 3

TABLE 2           TABLE 2
col1 | col 2      col1 | col 2
2    | 2          4    | 4
4    | 4          5    | 5
6    | 6          6    | 6
A: 

You need to capture the click event on both table headers and then replicate this to the other table. Tablesorter does have a sortStart event but doesn't pass in anything useful so you'd have to drill down and find the sort order and then call the 'sorton' event but this could trigger an endless loop if you're not careful. The author may be open to adding better hooks for this.

A better approach would be to merge the tables either server side or using jquery and just using tablesorter on the single table.

Brendan Heywood