无需重新加载网格的jqGrid'clearToolbar' [英] jqGrid 'clearToolbar' without grid reload

查看:90
本文介绍了无需重新加载网格的jqGrid'clearToolbar'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要清除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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆