开发者

Sorting table data across two table sets with jquery tablesorter

开发者 https://www.devze.com 2022-12-27 00:07 出处:网络
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?

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 开发者_如何学C   | 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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号