tablesorter 插件动态添加列 [英] tablesorter Plugin Add Column Dynamic

查看:37
本文介绍了tablesorter 插件动态添加列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用我的项目 Tablesorter 插件,我正在动态添加和删除列和行,同时删除列和行,

I am Using my project Tablesorter Plugin, I am Dynamic Added and Removed COLUMN and Rows, Also Delete Column and Rows,

删除列行和添加行可排序功能完美运行,

Remove Column Rows And Add Rows Sortable Function Working Perfectly,

但是添加新的动态列然后表排序器不起作用.

But Add New Column Dynamic Then Table Sorter Not Working.

请帮助我如何解决这个问题.

Please Help how i solve This Problem.

出现以下错误

**TypeError: h[list[i][0]] is undefined 

h[list[i][0]].addClass(css[list[i][1]]);**

我在表中创建动态列,然后单击新列标题.

I Create Dynamic Column in Table, and I am Click The New Column Header.

推荐答案

如果您添加或删除列,即使您触发了更新"方法,原始 tablesorter (tablesorter.com) 也将无法正常工作.它仅设计用于对 tbody 进行更改.

The original tablesorter (tablesorter.com) is will not work correctly if you add or remove columns, even if you trigger the "update" method. It is only designed to work with changes to the tbody.

您可以使用我的分叉的tablesorter通过触发<一个 href="http://mottie.github.io/tablesorter/docs/#updateall" rel="nofollow">"updateAll" 方法如下:

You can use my fork of tablesorter to work properly in your case by triggering the "updateAll" method as follows:

var resort = true, // re-apply the current sort
  callback = function(table){
    alert('table updated!');
  };

// let the plugin know that we made a update, then the plugin will
// automatically sort the table based on the header settings
$("table").trigger("updateAll", [ resort, callback ]);

请注意,sortList 选项 会更新从其初始设置开始并始终包含当前排序;但是,如果将新列插入到已排序列的左侧,它将不适用于同一列(它是一个从零开始的索引).

Please note, the sortList option does update from its initial setting and always contains the current sort; but, it will not apply to the same column (it's a zero-based index) if a new column is inserted to the left of that sorted column.

这篇关于tablesorter 插件动态添加列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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