问题描述
$ b
$(table)。我试图使用TableSorter和Widgets Scroller和Filters,它们工作得很完美。 tablesorter({
theme:'blue',
widgets:[zebra,filter,scroller]
});
但是,我的表开始为空或为空,并且在输入数据之后,我必须使用更新。
$(table)。trigger(updateAll)
这是我的问题,我无法同时使用Scroller和Filter,只是一个或另一个。
$ b(对不起,如果我的英文不好)
:
解决方案
- 过滤器小部件不会在空表上初始化。
- 滚动窗口小部件需要很多错误修复(我没有时间去做)
- 包括添加过滤器行(如果它在初始化时不存在)。
- 更新表格时完全移除滚动器小部件
- 等
li>
为了解决此问题,请尝试将附加代码更改为此():
$(#append)。click(function(){
//添加一些html
var html =< tr>< td> Aaron< / td>< td> Johnson Sr< / td>< td> ; / td>< / tr>,
// scroller在原始
$ table = $('table.update:last')之前创建表的克隆。
//将新的html附加到表体
$ table.find(tbody)。append(html);
//完全删除scroller部件
$ table.closest('。tablesorter-scroller')。find('。tablesorter-scroller-header')remove();
$ table
.unwrap()
.find('。tablesorter-filter-row')。removeClass('hideme')。end()
.find('thead ').show().css('visibility','visible');
$ table [0] .config.isScrolling = false;
//让插件知道我们进行了更新,然后插件将
//自动根据标题设置
$(table.update ).trigger( 更新);
返回false;
});
我会尝试修补,修正错误,并在我有空时完全重写scroller小部件。
I'm trying use TableSorter with Widgets Scroller and Filters, they work perfect,
$("table").tablesorter({ theme: 'blue', widgets: ["zebra", "filter", "scroller" ] });
But, my table begin null or empty and after I input the data, so I've to use Update.
$("table").trigger("updateAll")
There's my problem, I can't doing work Scroller and Filter at same time, just one or another.
Can someone help me?
(Sorry if my english is being bad)
Example:http://jsfiddle.net/s4ACj/5/
解决方案There are two issues.
- The filter widget does not initialize on an empty table.
- The scroller widget needs a lot of bug fixes (which I have not had time to do)
- including adding the filter row if it was not present on initialization.
- completely removing the scroller widget when updating the table
- etc.
In order to work around this issue, try changing your append code to this (update demo):
$("#append").click(function () { // add some html var html = "<tr><td>Aaron</td><td>Johnson Sr</td><td>Atlanta</td><td>GA</td></tr>", // scroller makes a clone of the table before the original $table = $('table.update:last'); // append new html to table body $table.find("tbody").append(html); // remove scroller widget completely $table.closest('.tablesorter-scroller').find('.tablesorter-scroller-header').remove(); $table .unwrap() .find('.tablesorter-filter-row').removeClass('hideme').end() .find('thead').show().css('visibility', 'visible'); $table[0].config.isScrolling = false; // let the plugin know that we made a update, then the plugin will // automatically sort the table based on the header settings $("table.update").trigger("update"); return false; });
I'll try to patch up, bug fix and probably completely rewrite the scroller widget when I have time.
这篇关于TableSorter过滤器和滚动器小部件更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!