The Filter Source property specifies the master data view that will pass down a filtering parameter to the child data view. The child data field that will be filtered is declared in the Filter Field property, and must be specified in addition to Filter Source in order for master-detail relationships to work. When the master data view has a compound primary key, up to 5 Filter Fields must be specified in order.
Let’s configure a master-detail relationship between Customers and Orders controllers in the Northwind database.
Adding the Page
Start the Project Designer. On the Project Explorer toolbar, click on the New Page icon.
Assign a name:
|Name||Customers and Orders|
Press OK to save. Switch to the Controllers tab. Select Customers controller node. While holding Ctrl key, select Orders node. Right-click on Orders, and press Copy.
Switch back to the Pages tab. Right-click on Customers and Orders node, and press Paste. The two controllers will be instantiated as data views in separate containers.
Configuring Master-Detail Relationship
However, these data views are currently independent from each other – a master-detail relationship must be configured.
Expand Customers and Orders / c102 / view2 (Orders) / grid1 node. Drop CustomerID –> CustomerCompanyName data field node onto Customers and Orders / c101 / view1 (Customers) node.
Because CustomerID field is matched to a similar field in Customers controller, a master-detail relationship is automatically configured. Filter Source is changed to “view1”, and Filter Field is changed to “CustomerID”. In addition, the Page Size has been changed to “5”, Auto Hide has been changed to “Container”, Show Modal Forms has been enabled, and Text is changed to the name of the controller, “Orders”.
On the Project Designer toolbar, press Browse. When generation is complete, navigate to the Customers and Orders page.
The page will initially only show a list of customers.
When a row is selected, a list of orders will appear underneath. These orders will be filtered by the value of “CustomerID” field in the selected row of “view1” data view (Customers).
Note that the filtered “CustomerID” data field in Orders view is hidden in order to prevent display of duplicate data. An SQL action may be implemented if the hidden foreign key field needs to be changed.