Question
“How do I link a pipeline (dataview) I’ve created in DADE with a standard pipeline I’ve placed on my form/datamodule or vice versa?”
Solution
Gain access to the pipeline object of the TppDataView via the daGetDataModule routine. Then manually link the pipelines as you would normally in code using a TppMasterFieldLink object.
Download: LinkDADEPipeToStandardPipe.zip
LinkStandardPipeToDADEPipe.zip
Sample Delphi code:
Link a DADE pipeline to a standard pipeline:
procedure TForm1.FormCreate(Sender: TObject);
var
lLink: TppMasterFieldLink;
lMasterPipeline: TppDatapipeline;
lDetailPipeline: TppDatapipeline;
begin
lMasterPipeline := plCustomer;
lDetailPipeline := GetDADEDataPipeline(ppReport1);
lDetailPipeline.MasterDatapipeline := lMasterPipeline;
lLink := TppMasterFieldLink.Create(nil);
lLink.Parent := lDetailPipeline;
lLink.Name := lDetailPipeline.GetValidName(lLink);
lLink.DetailFieldName := 'CustNo';
lLink.MasterFieldName := 'CustNo';
end;
function TForm1.GetDADEDataPipeline(aReport: TppReport): TppDataPipeline;
var
lDataModule: TdaDataModule;
lDataview: TdaQueryDataview;
begin
lDataModule := daGetDataModule(aReport);
if (lDataModule <> nil) then
begin
lDataview := TdaQueryDataview(lDataModule.DataViews[0]);
{need to set active true in order to use the link on the
pipeline so DADE won't try to fire the MAGIC SQL generation.}
lDataView.Active := True;
Result := lDataview.DataPipelines[0];
end
else
Result := nil;
end;
Link a standard pipeline to a DADE pipeline:
procedure TForm1.FormCreate(Sender: TObject);
var
lLink: TppMasterFieldLink;
begin
ppDBPipeline1.MasterDataPipeline := GetDADEDataPipeline(ppReport1);
lLink := TppMasterFieldLink.Create(ppDBPipeline1);
lLink.Parent := ppDBPipeline1;
lLink.Name := ppDBPipeline1.GetValidName(lLink);
lLink.DetailFieldName := 'CustNo';
lLink.MasterFieldName := 'CustNo';
end;
function TForm1.GetDADEDataPipeline(aReport: TppReport): TppDataPipeline;
var
lDataModule: TdaDataModule;
begin
lDataModule := daGetDataModule(aReport);
if (lDataModule <> nil) then
Result := lDataModule.DataViews[0].DataPipelines[0]
else
Result := nil;
end;