Using svyToolbarFilter with more than one grid

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Using svyToolbarFilter with more than one grid

Postby pitc » Mon Dec 07, 2020 5:12 pm

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?
Tom
prospect-saas.com
pitc
 
Posts: 115
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada

Re: Using svyToolbarFilter with more than one grid

Postby paronne » Mon Dec 07, 2020 6:06 pm

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
paronne
 
Posts: 202
Joined: Fri Nov 02, 2012 3:21 pm

Re: Using svyToolbarFilter with more than one grid

Postby pitc » Mon Dec 07, 2020 8:53 pm

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
Tom
prospect-saas.com
pitc
 
Posts: 115
Joined: Thu Nov 14, 2019 2:22 pm
Location: Ottawa, Ontario, Canada

Re: Using svyToolbarFilter with more than one grid

Postby paronne » Tue Dec 08, 2020 9:42 am

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
paronne
 
Posts: 202
Joined: Fri Nov 02, 2012 3:21 pm


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 12 guests

cron