0

I am using a jqGrid with both filterToolbar and searchGrid.

When I perform a search using the filterToolbar and then open the searchGrid window, the filters come filled fine.

But when I change something after this, this feature stop working.

I can explain by testing this sample: http://srv04.wln.com.br/cpsadmin/sample

Try typing an 'a' for the fields Name, Address and City in the filterToolbar, then perform a search (pressing return when focus in any input).

After that, click in the 'Find Records' button at the footerBar, this will open the search window, with the 3 fields filleds according with the filterToolbar searchoptions.

But if we try to do something after this, nothing works ok again, since we refresh the page.

I would like to get the power of both, filterToolbar and searchGrid, working together, and in the two ways.

iuristona
  • 927
  • 13
  • 30
  • It would be better if you would use `jquery.jqGrid.src.js` instead of `jquery.jqGrid.min.js` on the demo page http://srv04.wln.com.br/cpsadmin/sample – Oleg Mar 15 '12 at 18:46
  • I recommend you additionally to information from my answer use always `gridview: true`. You get just additional performance improvement without any disadvantage. – Oleg Mar 15 '12 at 19:06

1 Answers1

1

You can try to add recreateFilter: true searching option. To be able to find the exact reason of the problem you should use jquery.jqGrid.src.js instead of jquery.jqGrid.min.js on your demo page.

I recommend you additionally to use refreshSerchingToolbar function which I suggested in the answer. One more answer with the demo could be also interesting for you. It show how to save last searching filter (and some other information) in the localStorage. At the visit of the same page the previous used searching filter will be applied.

UPDATED: It's a little the matter of the tasted, but I personally use the settings

$.extend($.jgrid.search, {
    multipleSearch: true,
    multipleGroup: true,
    recreateFilter: true,
    closeOnEscape: true,
    closeAfterSearch: true,
    overlay: 0
});

or some more advanced version as my default Advanced Searching settings. The recreateFilter: true like recreateForm: true for the form editing are always my default settings. I suggested many times (see here for example) to make the settings as jqGrid defaults, but the suggestings stayed unanswered. Tony (the developer of jqGrid) has another opinion on the subject.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thank you Oleg! The `recreateFilter: true` has solved "from filterToolbar to searchGrid" way. So, even knowing the searchGrid allows to use two or more filters for the same field, there is a way to get the way back? I mean, changing the options from the searchGrid, reflect to filterToolbar? Eg. the filterToolbar default filter are `'cn'`, so to get a more grained filter, I would like when the option on the searchGrid are changed to `'bw'` the same field on the filterToolbar assumes this beginsWith filter too. – iuristona Mar 15 '12 at 21:10
  • @Iuri: You are welcome! Did you looked [the answer](http://stackoverflow.com/a/6884755/315935) where I suggested to use `refreshSerchingToolbar` (see second paragraph of my answer)? It do exactly what you need. It updates the filter toolbar with the value from the `postData` which can be set by Advanced Searching dialog. You can specify [searchoptions.sopt](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:search_config#colmodel_options) in any column to change the order of the operations displayed in the Dialog. The first operation from `sopt` will be used by the filter toolbar. – Oleg Mar 15 '12 at 21:21
  • Thank you for attention. I saw your answer now, but unfortunally the [demo](http://www.ok-soft-gmbh.com/jqGrid/SimpleLocalGridWithSearchingToolbarAndAdvanceSearching.htm) are not working like you have explained in that [answer](http://stackoverflow.com/a/6884755/315935). – iuristona Mar 15 '12 at 23:36
  • @Iuri: What is not working exactly? Just try for example to filter for "test1" in the "Client" column. Try reorder the columns with Column Chooser navigator button, resize some column (change its width), then press F5 or reopen the page. You will see that the last settings will be restore. Open Advance Searching dialog and change "test1" to "test2" without changing of "contains" operation. You will see that the searching toolbar are updated. – Oleg Mar 15 '12 at 23:44
  • My bad. I tested again, and did exactly you made in the answer and yes, it works like you said. But, I am trying to change the default search filter. That what I feel didnt work. I typed test and choose ends with at the window, and it didnt fill the toolbar field. So, I am trying to change just the sopt at the window, you know? – iuristona Mar 15 '12 at 23:56
  • tomorrow I will study your function refreshSerchingToolbar trying to change this behavior. I want to e.g. in your demo, type test at the toolbar and so, change from 'contains' to 'ends with' at the advanced search window, expecting the field at the toolbar reamains filled, with the new sopt='ew' for the Client col. – iuristona Mar 16 '12 at 00:06
  • @Iuri: I don't think that it would be correct. The operation in the "Client" column is 'contains' so the field have to stay non field. The operations in the toolbar should not be changed corresponds to the changing in the advanced searching dialog. You should understand that in Advanced Searching dialog you can set filters which **can't be represented** with the filter toolbar. For example <=400 & >=200. So sometime the toolbar filters have to be stay empty, but Advanced Searching dialog can use there. – Oleg Mar 16 '12 at 00:19
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/8948/discussion-between-iuri-and-oleg) – iuristona Mar 16 '12 at 00:31