Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JQuery tablesorter插件-修改行后更新排序_Jquery_Sorting_Tablesorter - Fatal编程技术网

JQuery tablesorter插件-修改行后更新排序

JQuery tablesorter插件-修改行后更新排序,jquery,sorting,tablesorter,Jquery,Sorting,Tablesorter,我使用TableSorter2.0,并使用ajax更新单元格的值。在调用之后,我需要再次对行进行排序,但是$('#thisTable').trigger('update')对我没有帮助 我在处理单元格内的标记,但这不会是问题 $('#thisTable').tablesorter({ textExtraction: function(node) { return node.getElementsByTagName('input')[0].value; } }); 任

我使用TableSorter2.0,并使用ajax更新单元格的值。在调用之后,我需要再次对行进行排序,但是$('#thisTable').trigger('update')对我没有帮助

我在处理单元格内的标记,但这不会是问题

 $('#thisTable').tablesorter({
   textExtraction: function(node) {
     return node.getElementsByTagName('input')[0].value; 
   }
 });
任何帮助都将不胜感激

--
Kree

您可以在表格分拣机中找到答案。你必须触发另一个事件,这是我的代码

//append some content to the tbody
$('table').trigger('update');    
var $sort = $('table').get(0).config.sortList;
$("table").trigger("sorton",[$sort]); 

在我将一些行添加到表体后,将调用上面的代码。我可以看到$sort值,但是触发器函数没有对新添加的行进行排序。

我在源代码中做了一些小改动。我已经向更新事件处理程序添加了一个参数来请求排序

$(“#MyTable”)。触发器('update')
将正常工作

$(“#MyTable”)。触发器('update',true)
将在更新后请求排序

$this.bind("update", function (e, sort) {
   var me = this;
   setTimeout(function () {
       // rebuild parsers.
       me.config.parsers = buildParserCache(
       me, $headers);
       // rebuild the cache map
       cache = buildCache(me);
       // ADDED
       if (sort) $(me).trigger('sorton', [me.config.sortList]);
   }, 1);
});

关于“更新”活动的实施, 它在1毫秒的超时后执行更新。 eather此函数应在表分类器中重写,eather使用回调

$this.bind("update", function () {
  var me = this;
  setTimeout(function () {
    // rebuild parsers.
    me.config.parsers = buildParserCache(
    me, $headers);
    // rebuild the cache map
    cache = buildCache(me);
}, 1);

是的,我读过,但我不知道,更新之前对哪个列进行了排序。。。sorton需要排序列作为参数。实际的排序列存储在:$(“#thisTable”).get(0.config.sortList中。如果未定义,您可以添加一些默认排序。谢谢!就是这样,我需要的!:)我启用了表格分拣机的调试模式。update触发器更新表缓存,但是sorton触发器正在对以前缓存的数据进行排序。因此,新数据没有得到排序。为了使它们同步,我放置了$(“table”).trigger(“sorton”,“[$sort]);在setTimoutblock中,延迟50ms。但这只是一个解决办法,但我想这不是正确的解决办法。有人能建议正确的修复方法吗?这应该是tablesorter源代码可以接受的特性。您是否尝试在github上提供此内容?但不确定触发索顿的原因。可能有更直接的方法吗?