Page 1 of 1

Using svyToolbarFilter with more than one grid

PostPosted: Mon Dec 07, 2020 5:12 pm
by pitc
Currently (as of 2020.12) the svyToolbarFilter allows only a single grid to be bound.
I have a use case where I have one form with two grids and I want to use the tool bar filter to search in either of the two grids.
I want the user to only have to type in one search field (I am using Navbar) and search on both grids.
I was wondering if I can do this with current implementation by having a second tool bar filter "hidden" that gets invoked only if the first one does not find any records.
Or, can the svyToolbarFilter be extended to allow a second grid to be searched/filtered given the priority of search/filter order.
Are there other approaches?

Re: Using svyToolbarFilter with more than one grid

PostPosted: Mon Dec 07, 2020 6:06 pm
by paronne
Hi,

in current version, the svyToolbarFilter is (yet) strongly tied to a Data Grid; most importantly the svyToolbarFilter is tied to a specific foundset to be queried.
Having 2 grids i expect each grid is bound to a different foundset, therefore you would need a svyToolbarFilter object for each grid.
Having a common search field to be used as Free Search input is possible since the free-search is triggered programmatically;
therefore you can have 2 toolbar filter object (1 per grid) and run a search on both as per your need.

Code: Select all
// run a free search across all columns
   toolbarFilter.setSearchText(searchText);
   toolbarFilter.search();
// run a free search across all columns of second grid
   toolbarFilter2.setSearchText(searchText);
   toolbarFilter2.search();


See wiki on how you can customize the free search for svyToolbarFilter: https://github.com/Servoy/svyPopupFilte ... arch-usage

Regards,
Paolo

Re: Using svyToolbarFilter with more than one grid

PostPosted: Mon Dec 07, 2020 8:53 pm
by pitc
Thanks Paolo, good ideas.
In my use case the first grid is a list (of persons) records and the second list is a related list (of a person's orders). So not independent.
I do see having two svyToolbar filters but how could I ensure that the person grid is executed before the related grid?
I guess I can copy the text for searching to the two filters (so only a single text field for the user).
Tom

Re: Using svyToolbarFilter with more than one grid

PostPosted: Tue Dec 08, 2020 9:42 am
by paronne
Hi Tom,

the code snippet from my previous post should work just fine for the scenario you describe.
You can also check if any person record has been found before triggering a search for person's orders.
Similar script to the one above, which can be called at the text input data change:

Code: Select all
// run a free search across all columns of persons grid
   personsFilter.setSearchText(searchText);
   personsFilter.search();

   // check if any person record has been found
   if (personFoundset.getSize()) {
       // run a free search across all columns of person's orders grid
       ordersFilter.setSearchText(searchText);
       ordersFilter.search();
   }


Regards,
Paolo