ComponentOne True DataControl 8.0
Master-Detail Relationships

Without writing any code, you can implement master-detail (one-to-many) relationships between a pair of TData controls. Master-detail relationships are unavailable in the Lite version.

At design time, set the Master property of the detail control (also referred to as the dependent control) to the name of the master control. You cannot change the Master property in code at run time.

Suppose, for example, that TData1 is bound to a customer database (master), and TD ata2 is bound to an orders database (detail). After setting the Master property of TData2 to TD ata1, you would typically specify a range condition that relates the CustomerID field of the detail control (TD ata2) with the corresponding field in its master control (TD ata1):

Example Title
Copy Code
TData2.CustomerID = TData1.CustomerID

See Field Range Conditions for details.

At run time, when the master control (TD ata1) is repositioned to a different record, or the value of its CustomerID field changes, the dependent control (TD ata2) is automatically refreshed, and any data-aware controls bound to it are refreshed accordingly.

Note that using range conditions is just one way to establish master-detail relationship between two TData controls. You can also use filters, SQL parameters, or other expressions based upon field values in the master control, as all master fields are available to dependent control(s).

If a master control has a master itself, then the "higher" master is called an ancestor of the "lower" master’s dependents. The fields of all ancestors are available to a dependent control, not just the fields of the control specified in the Master property.

The refresh of a dependent control is governed by its AutoRefresh property setting. The default setting is 2 – When Idle. This means that refresh takes place after every change in master, but not immediately. The dependent control is refreshed when the TData control has finished all other tasks, and is idle. This optimizes the refresh process for fast navigation, such as when multiple master records are displayed in a bound grid. With this setting, the user will not notice any delay other than that needed to retrieve the master records. For example, if the user presses the down arrow key on a master grid in quick succession, the master TData control will not refresh the detail records until it stops receiving notifications caused by repetitive keyboard activity.

If AutoRefresh is 1 - Immediate, any change to the value of a master’s field or parameter, as well as any repositioning of the master’s current row, immediately triggers the refresh of the dependent control. Since this can be a time-consuming operation, the 1 - Immediate setting is recommended only for forms that display one master record at a time.

To suppress automatic refresh of a dependent control, set its AutoRefresh property to 0 - None. You can always refresh the dependent control programmatically by calling its Refresh method.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback