Has*_*anG 8 javascript jquery tablesorter
我有一个用ajax更新的表,并在更新之后如果排序但我需要排序不是固定列,而是在更新之前最后点击的同一列.
function tableUpdated() {
$(".tablesorter").trigger("update");
//alert($(".tablesorter").sorting);
var sorting = [[7, 0]];
$("table").trigger("sorton", [sorting]);
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我需要将我选择的列索引而不是7
jQuery .data()会帮助你.每当用户单击以对表进行排序时,将列存储在表本身上.在sort函数中,添加:
$("#table").data('sorting', selectedColumn);
Run Code Online (Sandbox Code Playgroud)
现在元素具有值为的id="table"属性.在tableUpdated中,您可以使用以下数据:sortingselectedColumn
function tableUpdated() {
$(".tablesorter").trigger("update");
var sorting = [[$("#table").data('sorting'), 0]];
$("#table").trigger("sorton", [sorting]);
}
Run Code Online (Sandbox Code Playgroud)
使用的数据.data()可能更复杂,允许您添加数据对象.有关详细信息,请参阅此页面.
| 归档时间: |
|
| 查看次数: |
8564 次 |
| 最近记录: |