In jqgrid why dont toolbarfilter and Multiple Search filter get along (when using stringResult: true)

I have a website with jqgrid and I want to use both:

  • Toolbar Search
  • Advanced multi-user search (using multipleSearch: true )

I am using setupbarfilter using:

$("#grid").jqGrid('filterToolbar', { stringResult: true, searchOnEnter: true }) 

Thus, users have 2 ways to filter.

My problems:

  • Toolbar text is deleted after the advanced filter (and is not taken into account in the search request)
    If I have a search in the toolbar and press enter. works great. If I then click on the preliminary multi-user search and enter some criteria, it will “overwrite” the filter criteria, but it leaves the text in the filter panel of the toolbar, so when you see results that are confusing, because the result set does not match what you see in the filter text of the toolbar.

  • Going back and forth does not respect each other. I set up the initial set of multiple filters, it works fine. Then I enter some text into the filter of the toolbar and press enter, it sends ONLY this filter, which forms the toolbar to the server (thus overwriting the existing filters installed from the preliminary filter that have now disappeared). If I go back to the advanced filter, it will show the old filter that I originally sent (not the last filter that was created from the toolbar filter). Is there anyway toolbarfilter and advancedfilter can work together and always create a cumulative filter from both inputs of the UI, rather than overwrite each other in a server request.

So, basically in both of the use cases above, it seems that you shouldn't use both forms of filtering together, as they don't seem to play well together.

Update:

This image is in response to Oleg’s first answer: enter image description here

0
jquery user-interface filter jqgrid
Mar 12 2018-11-11T00:
source share
1 answer

Everything you do is absolutely true. I would recommend that you continue to use the same configuration: a toolbar to quickly, intuitively and easily search / filter data and search to advance search to create more complex filters.

In the current version of jqGrid, the pre-search module uses postData.filters to load the source filters. The toolbar filter on the other side does not read data from postData.filters and simply sets it.

If you want to keep separate filters for the toolbar and continue the search, I can suggest the following trick. You can open the advanced filter right after mesh initialization. The adnavce search module reads postData.filters first time the dialog is opened, only if the default recreateFilter: false and loadDefaults: true . After opening, you can immediately close the search dialog box, which will be disabled and will not be deleted.

 var grid = $("#list"), prmSearch = {multipleSearch:true,overlay:false}; grid.jqGrid({ // ... jqgrid parameters }); grid.jqGrid('navGrid','#pager', {add:false,edit:false,del:false,search:true,refresh:true}, {},{},{},prmSearch); // open the advance searching dialog grid.searchGrid(prmSearch); // close the advance searching dialog $("#fbox_"+grid[0].id+" div.ui-closer").trigger("click"); grid.jqGrid('filterToolbar',{defaultSearch:'cn',stringResult:true}); 

Thus, you can use both the toolbar and the advanced search using separate filters. Due to the use of the overlay:false parameter in the search dialog, you can even reset the mesh filters in the toolbar search without closing the preliminary search dialog.

You can see the corresponding demo here .

UPDATED : Another demo uses toggleToolbar to hide the filter toolbar if the advanced dialog is open and shown if the advanced dialog is closed.

UPDATED 2 : In another answer, you will find how to remove the last line of the search dialog (with "Inv No") which are not part of the search rules from postData.filters . The new version of the demo is here .

+1
Mar 12 '11 at 18:04
source share



All Articles