skip to main content
OpenEdge Development: ADM and SmartObjects
Data Management in the ADM : Filtering records
 
Filtering records
You use the SmartFilter to allow your application users to filter records with user‑specified selection criteria rather than built‑in criteria. The SmartFilter follows the query‑by‑form model and is implemented as a dynamic SmartObject; that is, the selection criteria are specified at run time rather than being built into the object.
Progress provides the prebuilt master dynfilter.w for the SmartFilter. When you build a SmartFilter, you must define a Filter link to connect the SmartFilter to the SmartDataObject that will serve as its data source, optionally defining that SmartDataObject at this time. (You also can define it later in the instance properties dialog box.) The Filter link can be implemented as a pass‑through link (see the “Pass-through links” section.) This allows you to create a SmartFilter in a separate SmartWindow and wait to link it to the Filter‑target until you drop the SmartFilter’s SmartWindow into the Filter‑Target’s SmartWindow.
Because the SmartFilter is implemented as a dynamic SmartObject, it does not have a wizard, and you modify it at design time through its instance properties. You can specify both the SmartDataObject that will serve as the data source for the records to be filtered and the fields the application user can filter. (See the “Customizing SmartFilters” section.) At run time, the user specifies selection criteria in the filter fields.
The SmartToolbar contains a Filter button that can start a SmartFilter. If the SmartFilter is in the same window as the SmartToolbar, it simply uses a Filter SmartLink. For instructions on linking the SmartToolbar if the SmartFilter is in a separate SmartWindow, see the “Connecting to a SmartFilter in another SmartWindow” section.
Customizing SmartFilters
You customize the SmartFilter object through its instance properties. The SmartFilter has an instance properties dialog box (source program: src/adm2/support/filterd.w) that you can use to specify various filter properties. Unless you linked to a data source before you opened the instance properties dialog box, you must at least customize your SmartFilter by providing it with a SmartDataObject that will serve as its data source. By default, all fields are selected, but you can add or delete fields and change the order in which they appear. Because SmartFilter fields are generated dynamically, you cannot access their properties in the instance properties dialog box; however, you can access the most important field properties for each field: its label, width, tooltip, and HelpID.
You also can specify some additional properties of the filter itself:
*Its style: Implicit, Explicit, Range, or Inline.
*Whether filter data in a character field is evaluated with BEGINS.
*Whether an Explicit operator is visualized using a combo box or a radio set.
See Chapter 2, “SmartObjects,” for descriptions of SmartFilter instance properties.
Connecting to a SmartFilter in another SmartWindow
To link the Filter button in a SmartToolbar to a SmartFilter in a separate SmartWindow:
1. Create a SmartFilter in a separate SmartWindow, specifying all necessary instance properties, and link it temporarily as a Filter‑Source to THIS-PROCEDURE (the SmartWindow).
2. Drop this SmartWindow in a SmartWindow with a potential filter—a SmartDataObject that matches the SmartFilter—and answer Yes to the Link Advisor’s prompt about adding the Filter link to the SmartDataObject.
3. Optionally, specify HideOnInit and DisableOnInit in the SmartWindow’s instance properties dialog box, and start the main SmartWindow.
4. Check the Filter check box in the SmartToolbar’s instance properties dialog box.
The SmartToolbar can now view and start the SmartFilter’s SmartWindow.