1)表分类器解析器,用于在页面加载时加载行中的下拉字段,但如果我尝试编辑任何s然后尝试再次对列进行排序,则按原始值排序而不是新的价值,你能帮忙解决这个问题吗?
2)如果我尝试从下拉选项中选择新值,然后单击列标题进行排序然后它不起作用,为什么以及您知道如何解决这个问题吗?
我的代码现在看起来像这样:
$(document).ready(function() {
return $("#tab1").tablesorter({
widgets: ['zebra'],
headers: {
0: {
sorter: 'inputs'
}
}
});
});
$.tablesorter.addParser({
id: "inputs",
is: function(s) {
return false;
},
format: function(s, table, cell, cellIndex) {
var $c;
$c = $(cell);
if (!$c.hasClass("updateInput")) {
$c.addClass("updateInput").bind("change", function() {
return $(tab1e).trigger("updateCell", [cell, false]);
});
}
return $c.find("option:selected").text();
},
type: "text"
});
答案 0 :(得分:1)
Tablesorter在内部缓存表数据。更改数据时,必须通知tablesorter它应更新其缓存。使用
$("#tab1").trigger("update");
请参阅表格分拣机主页上显示此内容的appending table data with Ajax。