0
我有一个表,我存储一些数据。这些数据是从JSON结构数组中的code.php中返回的。jQuery插件tablesorter jSON:o未定义
$("#errtable").tablesorter();
$.getJSON("./include/code.php", {key:$('#key').val()}, function(data) {
// append the "ajax'd" data to the table body
$.each(data, function(key) {
$("#errtable > tbody").append("<tr><td>"+data[key].errorcode+"</td><td>"+data[key].errordescription+"</td></tr>");
});
// let the plugin know that we made a update
$("#errtable").trigger("update");
// set sorting column and direction, this will sort on the first and third column
var sorting = [[2,1],[0,0]];
// sort on the first column
$("#errtable").trigger("sorton",[sorting]);
});
问题是Firebug的显示了一个错误:
o is undefined [Break On This Error] o.count = s[1];
指:
function updateHeaderSortCount(table, sortList) {
var c = table.config,
l = sortList.length;
for (var i = 0; i < l; i++) {
var s = sortList[i],
o = c.headerList[s[0]];
o.count = s[1];
o.count++;
}
}
没有任何人可以帮我解决这个问题?
谢谢。
你有一个例子吗?我刚刚把$(“#errtable”)。trigger(“update”);没有排序var和它的作品。 – josemaria
正如我所提到的,问题是试图对不存在的列进行排序。这应该工作,如果我不是错误的:'var sorting = [[1,1],[0,0]];' 你可以提供你的应用程序或jsfiddle演示吗? – topek