0

Here I have a search form and a grid. The grid has configured a URL and datatype 'json'.

When search form submit, it will trigger grid reload, with parameters collected in the search form get submitted.

Now I want to add local filtering ability using filterToolbar. i.e. let the user filter the result on-screen. So the search form remains a server-search. The toolbar is for local-search.

I tried using beforeSearch and afterSearch

var g = $("#grid").filterToolbar({
    beforeSearch: function(){ g.setGridParam({datatype:'local'}); },
    afterSearch: function(){ g.setGridParam({datatype:'json'}); }
})

but it turn out that once datatype:'local' is applied, any search in filterToolbar will remove all record on screen.

As I still want the server-search, I don't use loadonce .

Any other way to do that?

jackysee
  • 2,051
  • 4
  • 32
  • 38
  • You wrote "I still want the server-search". If you implemented [advanced searching](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:advanced_searching) (`multipleSearch:true`) you need include `stringResult:true` option of the [filterToolbar](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:toolbar_searching) to have toolbar filtering compatible to advanced searching. So is you use server side searching in advanced version and you will have no problem to add searching filter in any grid without writing additional code on the server side. – Oleg Jul 13 '11 at 05:14
  • The UI required to lay the search criteria on a form above the grid. So I won't use advanced searching. – jackysee Jul 13 '11 at 05:48
  • I found that the problem of row disappear is somehow related to how addJSONData() handle things as described in http://www.trirand.com/blog/?page_id=393/bugs/json-local-search-bug/&value=addJSONData%20bug&type=1&include=1&search=1&ret=all but I'm not sure if it's a 'bug' or not. Surely I can monkey-patch but I prefer not to... – jackysee Jul 13 '11 at 05:55
  • I don't understand which kind of server-search you use. Look at the demo from [the answer](http://stackoverflow.com/questions/5688158/possible-to-make-jqgrid-search-box-stay-on-page/5689137#5689137). The search criteria are stay above the grid. Another point. do you use `addJSONData` to fill the grid? In any way you should post the code which shows how you use jqGrid. – Oleg Jul 13 '11 at 06:55
  • By server-search I mean I would do the search programmatically. With a separate handcrafted HTML form, when form submit collect values to `postData` of the grid and trigger `reloadGrid`. I don't use `addJSONData` but jqgrid itself will eventually call it when ajax return. That's why the `datatype` matters. – jackysee Jul 13 '11 at 07:10
  • Sorry, but I don't understand your requirements. Why you need filter data from one page of data if the data are on the server. What the user need is to see filtered data **not from the current page, but from the whole data source**. So I think you need implement the filtering on the server and not locally. – Oleg Jul 13 '11 at 10:01
  • The requirement is that (1)able to search with data from server (repeatable) and (2)able to filter data on screen. The reason for (2) is to provide some quick UI to let the user to look for data that already loaded. – jackysee Jul 14 '11 at 01:14

0 Answers0