TcxDBDataModeController.OnDetailFirst Event
Occurs before reopening the parameterized query linked to a detail data controller.
Declaration
property OnDetailFirst: TcxDBDataModeControllerDetailFirstEvent read; write;
Remarks
This event is only used in rare cases. The TcxDBProviderDetailFilterAdapter and TcxADOProviderDetailFilterAdapter classes can perform default actions for setting SQL SELECT parameters and reopening BDE and ADO queries respectively. If you use an ADO query, you just need to manually add the cxADOAdapters unit to the uses section of your form (for BDE queries this is not required).
Use the OnDetailFirst event to set the parameters of the parameterized query linked to a detail data controller and reopen it if needed. This event is generated when you expand the level displaying data from the current detail data controller and when moving focus from one detail data controller to another. The AReopened parameter determines whether the query needs to be re-opened. Set it to True if the query was reopened. If no changes were made, you need to set AReopened to False.
Sender specifies the TcxDBDataModeController object belonging to the detail data controller which displays the query data.
ADataSet specifies the parameterized query dataset.
AMasterDetailKeyFieldNames specifies the DetailKeyFieldNames property value of a detail data controller.
AMasterDetailKeyValues specifies a single value or an array of values for detail key fields identified by the AMasterDetailKeyFieldNames parameter.
The following image shows a fragment of the grid control with two details at level 1:
If you expand Detail 1, the OnDetailFirst event is generated with AMasterDetailKeyFieldNames set to ‘CustNo’ and AMasterDetailKeyValues set to 3042. If the parameterized query defined by ADataSet already presents data with parameter 3042, the query should not be reopened. In this case, you just have to call the First method for the ADataSet argument. If the query’s parameter is other than 3042, you should set a new parameter and reopen the query (set Active to True).
If you expand Detail 2, the AMasterDetailKeyFieldNames and AMasterDetailKeyValues parameters of the OnDetailFirst event are ‘CustNo’ and 3051 respectively.
Refer to the example linked to this topic.