tonytomov/jqGrid — Issue #211: Add support for conditionally reloading of grid after searching
Author: emielJ
Created: 2011-12-09 14:58:17+00:00
State: open

It would be nice to have a way to prevent reloading of the grid after the filter has changed. In my setup I first want to send the changed search expression to the server and then based on the response I want to be able to determine whether the grid has to be reloaded.

This feature can be easily implemented by changing the following snippet in `searchGrid` in source `grid.formedit.js` from

if ($.isFunction(p.onSearch)) {
p.onSearch();
}
$($t).trigger("reloadGrid", [{page:1}]);

into

var mustReload = true;
if ($.isFunction(p.onSearch)) {
mustReload = p.onSearch($t.p.filters);
}
if (mustReload !== false) {
$($t).trigger("reloadGrid", [{page:1}]);
}

Note: by using `!==` in stead of `!=` the grid reload is prevented only when exactly `false` is returned. When no return statement is used, nothing will be broken.

The same change could be made in for the `onReset` callback.