jqGrid 'clearToolbar' without grid reload

2019-05-12 04:39发布

I need to clear the toolbar without reloading the grid in my jqgrid. It should just reset the toolbar to its default values.

I tried using,

$("#TransactionsGrid")[0].clearToolbar();

My grid datatype:local and i don't use loadonce:true.

This made the toolbar clear and refresh the grid. I dont want that to happen.

Any ideas?

标签: jqgrid
1条回答
Rolldiameter
2楼-- · 2019-05-12 05:34

I find the question interesting.

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();
    }
});

The corresponding demo shows it live.

查看更多
登录 后发表回答