Groups on Variable at Runtime
Hi all,
I'va to create a report runtime. In this report there is a group based on
two fields in the database. So I created a variable, hang a method to the
OnGetText call to calculate the value. This variable I use as a breakname of
the group. Still the group won't break.
Does anyone maybe know why the group doesn;t break??
This is the code:
// the method for calculation
procedure DoCalcGroupVariable(Sender: TObject; var Text: String);
var
expr : string;
begin
expr :=
PVariableRecord(Variabelen.Objects[Variabelen.IndexOf(TppVariable(Sender).Name)]).Expression;
TppVariable(Sender).Value := CalcExpression(expr); // this is
something like table.field1 + table.field2
end;
// the creation of the group
rGroup := TppGroup(ppComponentCreate(Report, TppGroup));
rGroup.Report := Report;
rGroupBreakVariable := TppVariable.Create(Report.Detailband);
with rGroupBreakVariable do
begin
Band := Report.DetailBand;
Name := '_elmtvarGroupHeader1'
Username := Name;
spSetBounds(837,21,56,15);
CalcType := veDataPipelineTraversal;
CalcComponent := Report.DataPipeline;
New(VariableRecord);
VariableRecord.Name := rGroupBreakVariable.Name;
VariableRecord.Expression := xmlBand.Expression;
Variabelen.AddObject(rGroupBreakVariable.Name,TObject(VariableRecord));
TMethod(tmpGetTextMethod).Code := @DoCalcGroupVariable;
TMethod(tmpGetTextMethod).Data := rGroupBreakVariable;
OnGetText := tmpGetTextMethod;
Visible := true;
end;
rGroup.BreakType := btCustomField;
rGroup.BreakName := rGroupBreakVariable.Name;
rGroup.NewPage := true;
rGroupHeaderBand :=
TppGroupBand(ppComponentCreate(Report,TppGroupHeaderBand));
rGroupFooterBand :=
TppGroupBand(ppComponentCreate(Report,TppGroupFooterBand));
rGroupHeaderBand.Group := rGroup;
rGroupFooterBand.Group := rGroup;
I'va to create a report runtime. In this report there is a group based on
two fields in the database. So I created a variable, hang a method to the
OnGetText call to calculate the value. This variable I use as a breakname of
the group. Still the group won't break.
Does anyone maybe know why the group doesn;t break??
This is the code:
// the method for calculation
procedure DoCalcGroupVariable(Sender: TObject; var Text: String);
var
expr : string;
begin
expr :=
PVariableRecord(Variabelen.Objects[Variabelen.IndexOf(TppVariable(Sender).Name)]).Expression;
TppVariable(Sender).Value := CalcExpression(expr); // this is
something like table.field1 + table.field2
end;
// the creation of the group
rGroup := TppGroup(ppComponentCreate(Report, TppGroup));
rGroup.Report := Report;
rGroupBreakVariable := TppVariable.Create(Report.Detailband);
with rGroupBreakVariable do
begin
Band := Report.DetailBand;
Name := '_elmtvarGroupHeader1'
Username := Name;
spSetBounds(837,21,56,15);
CalcType := veDataPipelineTraversal;
CalcComponent := Report.DataPipeline;
New(VariableRecord);
VariableRecord.Name := rGroupBreakVariable.Name;
VariableRecord.Expression := xmlBand.Expression;
Variabelen.AddObject(rGroupBreakVariable.Name,TObject(VariableRecord));
TMethod(tmpGetTextMethod).Code := @DoCalcGroupVariable;
TMethod(tmpGetTextMethod).Data := rGroupBreakVariable;
OnGetText := tmpGetTextMethod;
Visible := true;
end;
rGroup.BreakType := btCustomField;
rGroup.BreakName := rGroupBreakVariable.Name;
rGroup.NewPage := true;
rGroupHeaderBand :=
TppGroupBand(ppComponentCreate(Report,TppGroupHeaderBand));
rGroupFooterBand :=
TppGroupBand(ppComponentCreate(Report,TppGroupFooterBand));
rGroupHeaderBand.Group := rGroup;
rGroupFooterBand.Group := rGroup;
This discussion has been closed.
Comments
rather than using method 'OnGetText' you should use 'OnCalc' to calculate the value.
HTH,
Chris Ueberall;
variable is easier to do this visually, but since you are in code, it is
easier to use the OnGetBreakValue event to build a string from the two
fields form the pipeline and then all you have to do is set the break value
in that event. No need for a TppVariable in this case.
--
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com