GridView.MasterRowGetChildList Event
Enables you to supply detail data manually.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v19.1.dll
Declaration
[DXCategory("MasterDetail")]
public event MasterRowGetChildListEventHandler MasterRowGetChildList
Event Data
The MasterRowGetChildList event's data class is MasterRowGetChildListEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
ChildList | Gets or sets a detail clone’s record list. |
RelationIndex | Gets the relation index that identifies the affected detail. Inherited from CustomMasterRowEventArgs. |
RowHandle | Gets the handle of the currently processed master row in the current View. Inherited from CustomMasterRowEventArgs. |
Remarks
The MasterRowGetChildList event is raised when a particular detail is about to be created. The event’s CustomMasterRowEventArgs.RowHandle and CustomMasterRowEventArgs.RelationIndex parameters identify the detail. To provide custom data for this detail, assign a proper list to the MasterRowGetChildListEventArgs.ChildList parameter.
The MasterRowGetChildList event can be used for the following purposes:
- substitute the actual detail data with data supplied manually;
- supply data to details that have no initial data (implement dynamic data loading). In this case, you will also need to handle the GridView.MasterRowGetRelationCount, GridView.MasterRowGetRelationName and GridView.MasterRowEmpty events. Please refer to the Working with Master-Detail Relationships in Code topic for details.
The MasterRowGetChildList event may fire multiple times for a single row during an application run. Moreover, in specific instances, the MasterRowGetChildList event fires twice when a row is expanded. If you perform lengthy operations within this event, or firing this event multiple times somehow affects performance, we recommend you implement data caching.
Example
In the Master-detail mode using events Demo Center demo, the MasterRowGetChildList event provides detail data to every master row. The data provided contains all the same records as shown on the root Data Grid level.
gridControl.DataSource = Fish.GetData(4);
// Handle the MasterRowGetChildList event to provide data for the current detail.
// The detail is identified by the master row handle and relation index.
gridView.MasterRowGetChildList += (s, e) => {
e.ChildList = Fish.GetData(4).ToList();
};