Home RAP

columns in trasversal (left to right)

edited February 2003 in RAP
Hi, I'm Nicoletta and I have a problem with RB.
I'm using RB 7.0.
I have a master and a detail.
Each detail can be have n records.
I using X columns in trasversal (left to right)
I must do so:

REC1 a b c
REC2 b c
REC3 a c d

but I don't able.
Is necessary a RAP or is possible to do it with only groups?

Thank you very much.
Bye Bye

Nicoletta

Comments

  • edited February 2003
    I assume that REC1 is a master record and that the subreport is set to
    traverse left to right. The a, b, c, d are records of the detail, which you
    want to print in predefined columns on the page. This may be possible. You
    can try setting Report.Engine.CurrentColumn in the Detailband's
    BeforeGenerate event, or if that doesn't work then try setting the
    Report.Engine.PrintPosRect.Left (in microns) in the same event.

    If those approaches don't work, then it may be necessary to move the draw
    commands for each 'row' of detail records.

    For example, let's say you have a,b, c, and d as record field values in your
    detail dataset. This allows you to compare the record value and place it in
    the proper column. The dataset is ordered by this field, so we can assume
    they are in the proper order, a,b,c,d even if any of them are not included
    in the dataset, such as b,c,d or a,b,d...

    Thus the native output is

    REC1 a b c
    REC2 b c
    REC3 a c d

    By moving the draw commands for REC2 b and c to the right, you can get
    REC1 a b c
    REC2 b c

    Then move the records for REC3 c and d to get

    REC1 a b c
    REC2 b c
    REC3 a c d

    This should be done in Delphi code before trying to code it in Rap. What I
    would do is create a class. In this class, call it TmyDetailDrawCommands.
    In this class, add an array property for the draw commands. Then add a
    method to add and remove a draw command. The draw commands should be placed
    in a TList created inside this class. The reason is that everytime the
    detail band prints, you can create one of these objects and place all of the
    draw commands for that detail in this object's list. Since you have N rows
    and a,b,c,d = 4 columns, you can expect to have N * 4 of these objects.
    Place these objects in a TList on a page by page basis. Use each object's
    OnDrawCommandCreate event to stick the draw command object in the proper
    DetailDrawCommands object. You know that there are 4 rows and you can check
    the current master record number that you are on, then you know which 'cell'
    on the page to place this object, since it maps 1:1 to the detail bands that
    print on the page, if they printed al the way across the page. Also, when
    each DetailDrawCommands object is created, then you can check the
    aPipeline['aFieldName'] for the a,b,c,d column value. This should be a
    property on the DetailDrawCommands object as well, because this way, you can
    easily know which column the draw commands it contains should be shifted to.
    Use the Report.OnEndPage event iterate through the TList of these objects
    and tell each of these objects to shift. There should be a Shift method on
    this class to do this so that it can then iterate through its draw commands
    that are placed in it, so, in reality, you don't need an array property on
    this class, unless you want to:) T he only other thing is to build 4
    variables or define constants that are the left positions in microns that
    each column starts at. This way you can shift the Left properties of the
    draw commands. You could pass this value in the call to Shift.

    Once this works, then you can port it to RAP code, possibly using a pass
    through function or two. The conversion routines may need to made into pass
    through functions (see ppToMMThousandths ppFromMMThousandths in
    ppUtils.pas).

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited February 2003
    thank you very much!
    now I try to use your solution.
    Bye
    Nicoletta
This discussion has been closed.