Subreport pipeline reference
I need to be able to hook up datapipelines to reports at runtime. For
the main pipeline it is easy:
oReport.DataPipeline := dpDataPipelineName;
I need to also hook up a subreport datapipeline, something along the
lines of:
oReport.DetailBand.GetSubReports('SubReportName').DataPipeLine :=
dpSubDataPipelineName;
Is this the right approach; if it is, what is the right syntax?
Thanks.
the main pipeline it is easy:
oReport.DataPipeline := dpDataPipelineName;
I need to also hook up a subreport datapipeline, something along the
lines of:
oReport.DetailBand.GetSubReports('SubReportName').DataPipeLine :=
dpSubDataPipelineName;
Is this the right approach; if it is, what is the right syntax?
Thanks.
This discussion has been closed.
Comments
If you need to search your main report for a specific subreport (or any
component) it is best to use an object loop. This will loop through each
object in each band where you can then single out any given report object
and change or set its properties. See the article below for an example of
this.
Note: Once you find the correct subreport, you can simply define the
TppSubreport.DataPipeline property to assign it to a pipeline.
----------------------------------------------
Tech Tip: Loop Thru All Objects in a Report
---------------------------------------------
A ReportBuilder report is composed of a set
of components. The basic structure is
Reports.Bands[].Objects[]
The bands and objects within the report can
be accessed directly by object name or
via the Bands and Objects array properties.
Below is an example of using the Bands and
Objects array properties to change the font for
all objects on a report.
uses
ppClass;
procedure AssignFontToReport(aFont: TFont; aReport: TppCustomReport);
var
liBand: Integer;
liObject: Integer;
lObject: TppComponent;
begin
for liBand := 0 to aReport.BandCount-1 do
for liObject := 0 to aReport.Bands[liBand].ObjectCount-1 do
begin
lObject := aReport.Bands[liBand].Objects[liObject];
if lObject.HasFont then
lObject.Font := aFont;
end;
end;
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for the example, I'm having trouble getting it to work. I may be
showing my lack of knowledge about oop.
I get an error message that TppComponent and TppChildReport are
incompatible.
function GetChildReport( oReport: TppReport ): TppChildReport;
var
x : integer;
y : integer;
begin
Result := Nil;
for x := 0 to ( oReport.BandCount - 1 ) do begin
for y := 0 to ( oReport.Bands[ x ].ObjectCount - 1) do begin
if ( oReport.Bands[ x ].Objects[ y ] is TppChildReport ) then
begin
Result := TppChildReport( oReport.Bands[ x ].Objects[ y ] );
exit;
end; // child report found
end; // band objects
end; // each band
end;
I am unsure why you are receiving this specific error. However, there will
never be a TppChildReport object on your report. A TppChildReport object is
the actual report layout you see when you select the subreport tab at the
bottom of the designer. Try changing the TppChildReport in your code below
to TppSubreport and see if that helps. Then you can still assign the
TppSubreport.Datapipeline property as you would a child report.
--
Regards,
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
I got it to work. Thanks for your help.
Anyone interested, this is the final version. This only returns the
first (and in my case only) instance of a subreport, so with multiple
subreports this would have to be modified.
function TTechnicianDailyService.GetSubReport(
oReport: TppReport ): TppSubReport;
var
x : integer; // bands
y : integer; // objects on band
begin
Result := Nil;
for x := 0 to ( oReport.BandCount - 1 ) do begin
for y := 0 to ( oReport.Bands[ x ].ObjectCount - 1) do begin
if ( oReport.Bands[ x ].Objects[ y ] is TppSubReport ) then begin
Result := TppSubReport( oReport.Bands[ x ].Objects[ y ] );
exit;
end; // child report found
end; // band objects
end; // each band
end;