Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Example: TcxDBDataModeController.OnDetailFirst

The TcxDBDataModeController.OnDetailFirst event handler is listed in the next example. It does not reopen the underlying query if it already contains the required data (the query parameter value is the same as the value of the detail key field name passed via the AMasterDetailKeyValues argument). In this case the current record is only positioned to the first record in the query dataset.

Otherwise the query with a new parameter value is reopened by setting the Active property to True. The AReopened parameter is set to True in this case.

procedure TForm1.DBTableView1DataControllerDataModeControllerDetailFirst(
  Sender: TcxDBDataModeController; ADataSet: TDataSet;
  const AMasterDetailKeyFieldNames: String;
  const AMasterDetailKeyValues: Variant; var AReopened: Boolean);
begin
  with (ADataSet as TQuery) do
  begin
    if ParamByName('CustNo').Value = AMasterDetailKeyValues then
    begin
      First;
      Exit;
    end;
    DisableControls;
    try
      Active := False;
      ParamByName(AMasterDetailKeyFieldNames).Value := AMasterDetailKeyValues;
      Active := True;
    finally
      EnableControls;
    end;
    AReopened := True;
  end;
end;