无需重新加载网格的jqGrid'clearToolbar' [英] jqGrid 'clearToolbar' without grid reload
问题描述
我需要清除toolbar
,而无需在我的jqgrid
中重新加载网格.只需将工具栏重置为其默认值即可.
I need to clear the toolbar
without reloading the grid in my jqgrid
. It should just reset the toolbar to its default values.
我尝试使用,
$("#TransactionsGrid")[0].clearToolbar();
我的网格datatype:local
,我不使用loadonce:true
.
这可以清除toolbar
并刷新网格.我不希望那样发生.
This made the toolbar
clear and refresh the grid. I dont want that to happen.
有什么想法吗?
推荐答案
我发现这个问题很有趣.
I find the question interesting.
要实现此要求,我建议使用寄存器jqGridToolbarBeforeClear
仅执行一次处理程序.处理程序应1)取消注册自己为事件处理程序,并返回停止"以防止重新加载网格:
To implement the requirement I suggest to use register jqGridToolbarBeforeClear
to execute the handler only once. The handler should 1) unregister itself as the event handler and return "stop" to prevent reloading of the grid:
$grid.jqGrid("filterToolbar", { defaultSearch: "cn" });
$("#clearToolbar").button().click(function () {
var myStopReload = function () {
$grid.unbind("jqGridToolbarBeforeClear", myStopReload);
return "stop"; // stop reload
};
$grid.bind("jqGridToolbarBeforeClear", myStopReload);
if ($grid[0].ftoolbar) {
$grid[0].clearToolbar();
}
});
相应的演示实时显示.
这篇关于无需重新加载网格的jqGrid'clearToolbar'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!