Pattern and Clone Views
- 3 minutes to read
This topic explains the mechanisms that the VCL Grid Control uses to display master-detail layouts and manage detail Views.
The most common Level-View structure that displays master-detail data includes one top Level and its child Level (for example, LevelCategories and LevelProducts in the image below), each with its own grid View assigned.
The detail View (ViewProducts) allows you to bind the details to data and customize their behavior and appearance. You can click the corresponding label in the Structure Navigator to access the View’s settings.
The following list describes the View technology’s key points:
- Each detail you see on screen is an individual grid View instance.
- The grid Views you customize at design time only store View settings. These Views called Pattern Views are never displayed and have no access to data.
- When you expand a master row, the grid control identifies the master-detail relationship to display and the pattern View associated with its details. The grid control creates a View instance of the same type as the pattern View and initializes the created instance with the pattern View’s settings. Such View instances visible on screen are called Clone Views.
- Clone Views can either exist independently from other clones and the pattern or get constantly synchronized. For instance, a user may filter one detail that does not affect the others.
- You can have multiple pattern Views per Level and use different Views and View types to visualize detail data. Refer to the following topic for more information: Grid Levels.
Runtime Detail Management
Detail management at runtime depends on whether you access the pattern View or a clone. The following rules allow you to select the object to access:
- Since pattern Views do not contain any information related to user actions or underlying data (such as the current selection, focus, and scroll position), you should obtain this information from the appropriate clone View object.
- If you disable View synchronization, you should not use the pattern View’s settings to change the View’s layout. For instance, changes made to the column order, or an element’s visibility or style have no effect on the displayed clones, unless you call a data controller’s ClearDetails or ClearDetailLinkObject methods to synchronize details manually.
Use the pattern View’s name to access the View and its settings in code. To access its clones and related master-detail data, use the following members:
- The grid control’s FocusedView property provides access to the focused clone View.
- The pattern View’s Clones and CloneCount properties allow you to iterate through all clones created for this pattern View.
- A clone View’s MasterGridView, MasterGridRecord, and MasterGridRecordIndex properties enable you to identify the master View and its record that displays the clone View.
- The
Sender
parameter in the pattern View’s event handler allows you to access the clone View that raised the event. For instance, when a user clicks a column header in a clone View, the column raises the OnColumnHeaderClick event and passes this clone View as theSender
event parameter.