Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Groups on Variable at Runtime

edited May 2003 in General
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;

Comments

  • edited May 2003
    Hi Jos,

    rather than using method 'OnGetText' you should use 'OnCalc' to calculate the value.

    HTH,
    Chris Ueberall;
  • edited May 2003
    Try coding the TppGroup.OnGetBreakValue instead of using a variable. Using a
    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


This discussion has been closed.