frxReport1GetValue

edited 6:13PM in FastReport 3.0
Hi,

I need only one userdataset, which is use for two blocks master and detail. And now I use frxReport1GetValue for geting data to report. But on preview is only one record for examle:

On preview:
Jan Novak
CPU
Monitor
Keyboar

But If I use two userdatasets, then everything is ok, there are all records. But point is, I need only one function frxReport1GetValue, because I don't know how many blocks will be on report.

On preview:
Jan Novak
CPU
Monitor
Keyboard

Pavel Haka
Mouse
USB
Soundcar
...


procedure TForm1.frxReport1GetValue(const VarName: String;
var Value: Variant);
begin
if CompareText(VarName, 'person.firstname') = 0 then
Value := ar1;
if CompareText(VarName, 'person.surname') = 0 then
Value := ar2;
if CompareText(VarName, 'thing.name') = 0 then
Value := ar3;
end;

Thank you for your help and sorry for my english.

Comments

  • edited 6:13PM
    the 'i' should be frxUserDataSet1.RecNo
  • edited 6:13PM
    xiaomaoxia wrote:
    the 'i' should be frxUserDataSet1.RecNo
    No, it isn't problem. So I try show you a code.
    var
      ar: array[0..9] of Integer = (0,1,2,3,4,5,6,7,8,9);
      adrr: array[0..9] of String = ('a','b','c','d','e','f','g','h','i','j');
      i:integer;
      DB: TfrxUserDataSet;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
     i:=0;
     DB:=TfrxUserDataSet.Create(self);
    
     DB.UserName:='DB';
     DB.RangeEnd := reCount;
     DB.RangeEndCount := 10;
    
    
     frxReport1.DataSets.Add(DB);
    
     DB.OnGetValue:=frxReport1GetValue;
    
     DB.Fields:=ParseXMLtoFRList(LoadXMLFile('database.xml'));
    
    frxReport1.DesignReport;
    end;
    
    procedure TForm1.frxReport1GetValue(const VarName: String;
      var Value: Variant);
    begin
      if CompareText(VarName, 'person.firstname') = 0 then
        Value := ar[DB.RecNo];
       if CompareText(VarName, 'thing.name') = 0 then
        Value := adrr[DB.RecNo];
    
    end;
    

    So on report designer:

    ********************master************************************DB*
    DB."osoba.name"
    ****************************************************************

    ********************detail**************************************DB*
    DB."thing.name"
    *****************************************************************

    Preview:
    0
    a
    b
    c
    d
    e
    f
    g
    h
    i
    j

    nothing else

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.