Jayanta Deb
Jayanta Deb

Reputation: 1

Client side search with filterToolbar does not work first time

I have a jqGrid on which I call filterToolbar and set loadonce=true. When I start searching the search does not work the first time. Second time onward the search works great. Any idea? jqGrid('filterToolbar', {stringResult: false, searchOnEnter: false, enableClear: false, beforeSearch: function () { presenter.grid.setGridParam({loadonce: "true"}); }, afterSearch: function () { }});

Upvotes: 0

Views: 275

Answers (1)

Oleg
Oleg

Reputation: 221997

First of all, the value of loadonce should be Boolean instead of String: (loadonce: true instead of loadonce: "true").

Seconds, loadonce will be used only during processing of the data loaded from the server. If loadonce: true is not set, then the HTML table will be filled with the data, but the server respond and the data returned from the server will not be saved locally. On the other side if loadonce: true then jqGrid saves the data returned from the server in the local jqGrid option data. But I have to repeat that jqGrid fills the data only during processing of the server response. Additionally jqGrid changes the option datatype to "local" at the end of processing the data, if loadonce is true. Thus all will looks later like local filled grid: datatype is "local" and data option is filled with data (all pages of data).

Your current code just set loadonce option to true. It don't fills data option and don't changes datatype to "local". Instead of that jqGrid will continue processing of the current filtering request and it will send the request to the server. Only after processing of the server response (the request to return filtered data), jqGrid will take in consideration loadonce: true option, it will fill data and it will change datatype to "local".

Upvotes: 0

Related Questions