Data Controllers / Fields

  Items Data View

Table of Contents
Data Controllers / FieldsPrint||
Items Data View

Lookup fields, when activated, display a view to allow the users to select an item. By default, the first grid view in the controller is used. Let’s create and use an alternate view for the CustomerID lookup field in the Orders controller.

Start the Project Designer. In the Project Explorer, switch to the Controllers tab. Right-click on Customers / Views and select New View option.

Create New View in Customers controller in Code On Time Project Explorer.

Configure the new view with the following values:

Property Value
Id grid2
Type Grid
Command command1
Label Customers from USA
Header Text This is a list of customers from the United States.
Filter Expression Country='USA'

Press OK to save the view.

Next, add all data fields that exist in grid1 except Country. In the Project Explorer, right-click on Customers / Views / grid2 node, and select New Data Field option.

New Data Field in 'grid2' view of Customers controller.

Specify the field name for the data field:

Property Value
FieldName CustomerID

Press OK to save the data field. Create the rest of the data fields:

Field Name
CompanyName
ContactName
ContactTitle
Address
City
Region
PostalCode
Phone

On the toolbar, press Browse. When the application starts in the web browser, navigate to Orders page. Edit a record, and activate the lookup for Customer Company Name.

Customer Company Name lookup on the Orders edit form.

The lookup window will display Customers (grid1) view. Click on the View dropdown on the right side of the action bar and select Customers from USA. The view grid2 will be displayed, showing only customers from USA. There will not be a Country column.

Select Customers from USA view using the view selector.

Let’s configure Orders.CustomerID lookup field to use grid2 by default. Switch back to the Project Designer. Double-click on Orders / Fields / CustomerID field node.

CustomerID field of Orders controller.

Change the Items Data View property:

Property New Value
Items Data View grid2

Press OK to save the field. To prevent users from selecting Customers from USA view on other pages, let’s remove the view from the view selector.

In the Project Explorer, double-click on Customers / Views / grid2 view node.

image

Prevent the view from showing up in the view selector:

Property New Value
Show in View Selector False

Press OK to save the view. On the toolbar, select Browse. Navigate to the Orders page, and edit a record. Activate the Customer Company Name lookup. The grid2 view will be displayed.

Customer Company Name lookup using the 'Customers from USA' view.