Property Context Fields can list static values that can be used as lookup field filters.
For example, the CategoryID lookup field on the Products edit form displays eight categories available for selection.
Let’s specify static filter values for the CategoryID lookup data view.
Start the Project Designer. In the Project Explorer, switch to Controllers tab. Double-click on Products / Fields / CategoryID field node.
Change the Context Fields property:
Property | New Value |
Context Fields | CategoryID=1, CategoryID=5 |
Press OK to save the field.
CategoryID refers to the primary key of Categories controller. Any other data field in grid1 can be referenced as well.
On the toolbar, press Browse.
Navigate to the Products page, and edit a record. Activate the CategoryID lookup – only two items will be displayed.
If the lookup filter fields are text based, then the value must be surrounded by single quotes. For example, let’s use the field CategoryName as a context filter.
Change the Context Fields property of Products / Fields / CategoryID as shown next:
Property | New Value |
Context Fields | CategoryName='Seafood', CategoryName='Dairy Products' |
Press OK to save the field. On the toolbar, select Browse.
Navigate to Products page, and edit a record. Activate the CategoryID lookup – only two categories will be available for selection. Notice that the CategoryName field is hidden, since it is explicitly defined in the grid view.