A web seek form lets users search a large database without loading every object; use it when a ViewModel search must return a controlled number of matching records.
Limit returned rows with MaxFetch
Set the MaxFetch tagged value on the seeker search expression to limit how many records the search returns. This protects the form from presenting an unbounded result set and prompts the user to make the search more specific or continue through configured result pages.
If you do not set MaxFetch, the default maximum is 20 records.
Set MaxFetch
- In MDriven Designer, open the ViewModel that contains the seek form.
- Select the orange search expression that defines the search.
- Open its tagged values by using the Tagged value button, or use the property inspector.
- Add or change the tagged value named MaxFetch.
- Enter the maximum number of records that this search may return.
- Save the ViewModel and test the form with a search that has more matches than the configured limit.
For example, set MaxFetch to 50 on a Person seeker. A search that matches hundreds of persons returns at most 50 persons in vSeekerResult, rather than loading the full match set.
How the limit fits into a seeker
A seeker uses orange search expressions in the ViewModel. The search criteria are expressed in OCL and are translated to SQL for database evaluation. The resulting collection is placed in vSeekerResult.
For example, this criterion searches for persons registered on or after a date supplied by the user:
Person.allInstances->select(p|p.Registrered>=vAfterDate)->orderBy(p|p.Registrered)
In this example:
| Item | Purpose |
|---|---|
vAfterDate
|
A ViewModel variable of type DateTime. Using a date value, rather than text, lets the database evaluate the date comparison correctly.
|
vSeekerResult
|
The collection populated by seeker logic and normally shown in the result grid. |
MaxFetch
|
A tagged value that limits the number of result objects returned by the search. |
MaxFetch does not replace search criteria. Design the criteria so that users can narrow the result set, then use MaxFetch as the upper bound for each search response.
Show the active search or sort column
Use the tagged value Eco.HiliteGridColumn on a search expression when you want the web UI to indicate the column associated with the current search or sort order. Configure the tagged value on the orange search expression through the Tagged value button or the property inspector.
For example, if users search by a person's registration date and the expression orders by that date, apply Eco.HiliteGridColumn to that expression so the result grid can signal the relevant column.
Choose a suitable result strategy
| Need | Use |
|---|---|
| Return a fixed, bounded number of matches | Set MaxFetch on the search expression.
|
| Let users work through a result set that exceeds one fetch | Configure Search result pages. Paging uses known ViewModel variables, including result count, page length, and current page. |
Create or change search criteria and understand vSeekerResult
|
Follow Searching. |
| Learn the seeker pattern and date-search example in detail | See Seeker view. |
Test the seek form
- Enter criteria that should return fewer records than MaxFetch. Verify that the expected rows appear in the result grid.
- Enter broader criteria that should return more records than MaxFetch. Verify that the form returns no more than the configured maximum.
- If users must reach all matching records, configure and test result paging rather than raising MaxFetch without a defined limit.
- Test the search with realistic database volumes. A seeker is intended to filter in the database, not to load all instances into the ViewModel.
