Hello VascoMorais and derek,
The problem with multiple search fields is that it can become complicated when you have to test 3 or 4 fields for user inputs, leading to a veryyyyyyy looooong sequence of
in order ton cover all the combinations.
That is.... if you put the search logic in each "OnChange" events of your input components.
What I usually do is regroup all the search logic in one place, a procedure, that will take care of all the conditions.
From there, all I have to do is link your component's OnChange events to this single procedure.
In the attached example, your have two tables.
The first one is called asset and contains more or less 26.000 rows with for each
- a serial number (SKU number)
- an asset name
- an asset status (is it owned, wanted...)
- a reference to the second table
The second table only contains a text field, with the name of the vendor of the assets
Searching through 26.000 rows (my actual database has more than 300.000) can be heavy, especially if you want to be able to search on all table fields
In the fully commented code attached, you will see that :
- the search can be performed on 4 criteria at the same time
- when a field is empty the database filter is neutalized
- I define 4 variables for each possible filters and concatenate them in one single filter activated by each OnChange events of the components
Hope this helps a little
have a good day olds friends
1 - my database is 15 times larger than this sample, so I added a Timer event to delay the effect of the filter until the user stops typing
2 - The SKU filter operates with a LIKE only on the end of the serial number
3 - The asset name filter operates with a LIKE from both ends of the name
4 - The formatting of the TableGrid takes place only in it's OnChange event, this way I don't have to replicate this formatting for each changes
5 - I use Radiobuttons because the little hassle of creating them all is better than having to handle the logic behind 5 comboboxes when only one can be checked at a single time
I'm a very good housekeeper !
Each time I get a divorce, I keep the house