jQuery TableSorter 2.0-恢复排序顺序 [英] Jquery TableSorter 2.0 - Revert Sort order

查看:124
本文介绍了jQuery TableSorter 2.0-恢复排序顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部

我正在使用JQuery TableSorter插件.该表对所选列的排序很好.考虑到页面加载时没有进行排序.现在,如果表按一列排序,则它会排序.现在,在单击表外的还原排序"链接后,即使表排序器之前对多个列进行了排序,也应还原为初始排序顺序.我们如何实现这一目标?

I am using the JQuery TableSorter Plugin. The table sorts fine for the selected columns. Consider that when the page loads, there is no sorting taking place. Now, if the table is sorted by one column, it sorts. Now, upon clicking a "Revert Sort" link outside the table, the tablesorter should revert to the initial sort order, even if it sorted multiple coumns before. How can we achieve this?

谢谢

推荐答案

因此,"没有排序"表示您只是做

So by "there is no sorting taking place" you mean you just do

$("#myTable").tablesorter();

在单击链接后,您希望表格看起来像在此调用之后没有排序吗?

And after a click on a link you want the table to look like just after this call with no sorting done?

我认为没有简单的方法可以做到这一点.但是我提供了一个技巧,如何做到这一点,但是请注意,根据表的大小,这可能会占用大量的浏览器内存.

I don't think there is an easy way to do this. But I provide a hack how this could be done, but beware depending on the size of your table this might use up a good amount of browser memory.

这个想法是在应用tablesorter插件之前先复制表.稍后,当单击链接时,只需恢复表原样并重新应用tablesorter.例如

The idea is to copy the table before you apply the tablesorter plugin. Later when clicking the link just restore the table as it was and reapply tablesorter. e.g.

var tablebackup;
$(document).ready(function() {
  tablebackup = $("#myTable").clone();
  $("#myTable").tablesorter();
});

function resetTable() {
  tablebackup.clone().insertAfter("#myTable");
  $("#myTable").remove();
  $("#myTable").tablesorter();
}

请检查此示例以获取完整的工作示例 http://jsbin.com/ujiko (没有CSS或其他任何内容但有效)

Check this for a full working example http://jsbin.com/ujiko (no css or anything but works)

这篇关于jQuery TableSorter 2.0-恢复排序顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆