Skip to main content

TcxCustomDataController.GetDetailDataController(Integer,Integer) Method

Returns a clone of the detail data controller associated with a specific record in the current master data controller.

Declaration

function GetDetailDataController(ARecordIndex: Integer; ARelationIndex: Integer): TcxCustomDataController;

Parameters

Name Type
ARecordIndex Integer
ARelationIndex Integer

Returns

Type
TcxCustomDataController

Remarks

This method is applied to a non-pattern master data controller, i.e. to the master data controller whose IsPattern function returns False.

Use the GetDetailDataController function to return a clone of the detail data controller associated with a specific record in the current master data controller. The master record is identified by the ARecordIndex parameter, which specifies its record index (the position of the record in the underlying data source).

It is possible to set up several master-detail relationships for a single master data controller. In ExpressQuantumGrid, you usually create a structure of grid levels/Views to represent master-detail relationships. Every Grid View is linked to the corresponding data controller providing data to display. The following screenshot shows the Structure Navigator with a MasterTableView for which two master-detail relationships are created. The first relationship is between MasterTableView and DetailTableView1. The second relationship is between MasterTableView and DetailTableView2.

The ARelationIndex parameter specifies the zero-based index of a master-detail relationship for the current data controller. For the data controller of the MasterTableView in the image above, ARelationIndex can vary from 0 to 1.

The GetDetailDataController function can be used when populating detail data controllers in unbound mode. See the example below.

For information on representing master-detail relationships via data controllers, see the TcxCustomDataController topic.

Consider an example of displaying a master-detail relationship in ExpressQuantumGrid in unbound mode. The FMasterTableView and FDetailTableView Views represent master and detail Views respectively. The detail View contains three columns.

It is assumed that the master View contains only two records. Therefore, only two detail clones of the FDetailTableView View corresponding to these records exist. The following code shows how to populate both clones with data. The first detail clone will contain two records (the RecordCount property is set to 2), the second one will contain only one record.

var
  I: Integer;
  ADetDataController: TcxCustomDataController;
//...
  with FMasterTableView.DataController do
  begin
    BeginUpdate;
    try
      for I := 0 to RecordCount - 1 do
      begin
        ADetDataController := GetDetailDataController(I, 0);
        with ADetDataController do
        begin
          BeginUpdate;
          try
            case I of
              0:
              begin
                RecordCount := 2;
                Values[0, 0] := 'Io';
                Values[0, 1] := 422;
                Values[0, 2] := 1.77;
                Values[1, 0] := 'Europa';
                Values[1, 1] := 671;
                Values[1, 2] := 3.55;
              end;
              1:
              begin
                RecordCount := 1;
                Values[0, 0] := 'Moon';
                Values[0, 1] := 384;
                Values[0, 2] := 27.32;
              end;
            end;
          finally
            EndUpdate;
          end;
        end;
      end;
    finally
      EndUpdate();
    end;
  end;
See Also