Skip to main content
Table of Contents

TTMSFNCDataGridDatabaseAdapter.DetailControl Property

Control shown below a row when the user expands it, typically a second grid bound to a detail dataset.

API unit family: TMSFNCDataGridDatabaseAdapter Declaring type: TTMSFNCDataGridDatabaseAdapter Inherited from: TTMSFNCCustomDataGridDatabaseAdapter Type: TTMSFNCDataGridCellControl

Syntax

FMX.TMSFNCDataGridDatabaseAdapter.hppPascalC++
property DetailControl: TTMSFNCDataGridCellControl;
__property TTMSFNCDataGridCellControl* DetailControl = {read=FDetailControl, write=SetDetailControl};

Remarks

When assigned, every data row gets a collapsed child row that spans all data columns and is as high as the control. Expanding a row first moves the dataset to that record (so a master-detail link refreshes the detail data) and then places the control in the child row; collapsing removes it again. Only one row shows the control at a time.

The control is hidden while not in use at run time. The feature is disabled while the grid uses paging. The adapter is notified when the control is freed.

Usage examples

Combine side-by-side grids, inline detail, and manual synchronization

Wire dataset-backed master/detail grids, embed the detail grid under the selected row, and refresh custom state when selection changes.

Combine side-by-side grids, inline detail, and manual synchronizationPascalC++
procedure TForm1.FormCreate(Sender: TObject);
begin
  ConfigureMasterDetailDatasets;

  MasterAdapter.DataGrid := MasterGrid;
  MasterAdapter.DataSource := MasterDataSource;
  MasterAdapter.DetailControl := DetailGrid;

  DetailAdapter.DataGrid := DetailGrid;
  DetailAdapter.DataSource := DetailDataSource;

  MasterGrid.OnSelectCell := MasterGridSelectCell;

  MasterTable.Active := True;
  DetailTable.Active := True;
end;

procedure TForm1.MasterGridSelectCell(Sender: TObject;
  AStartCell, AEndCell, AFocusedCell: TTMSFNCDataGridCellCoord);
begin
  DetailGrid.AutoSizeColumns;
end;
void __fastcall TForm1::FormCreate(TObject *Sender)
{
  ConfigureMasterDetailDatasets();

  MasterGrid->Adapter = MasterAdapter;
  MasterAdapter->DataSource = MasterDataSource;
  MasterAdapter->DetailControl = DetailGrid;

  DetailGrid->Adapter = DetailAdapter;
  DetailAdapter->DataSource = DetailDataSource;

  MasterGrid->OnSelectCell = MasterGridSelectCell;

  MasterTable->Active = true;
  DetailTable->Active = true;
}

void __fastcall TForm1::MasterGridSelectCell(TObject *Sender,
  const TTMSFNCDataGridCellCoord &AStartCell, const TTMSFNCDataGridCellCoord &AEndCell,
  const TTMSFNCDataGridCellCoord &AFocusedCell)
{
  DetailGrid->AutoSizeColumns();
}

Read the related guide