tablesorter Plugin Add Column Dynamic

人盡茶涼 提交于 2019-12-24 10:58:09

问题


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.

I got The Following Error

**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.


回答1:


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.

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 ]);

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.



来源:https://stackoverflow.com/questions/21678671/tablesorter-plugin-add-column-dynamic

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!