Home General

Dynamic headers/footers

edited February 2016 in General
Hi list,

i would like to implement simple single reports which contain either a
header or a footer.
This reports should be dynamically included in other reports on
previewing or printing.
I have read
http://www.digital-metaphors.com:8080/Design/Layout/How_To...Standard_Header_Footer
and inspected Rbuilder\Demos\EndUser\Dynamic Subreport Loading.
As far as I have understood I will have to subclass TppSubReport for
loading the data. Eventhough there are some events like page counting
which have to be redirected.
These new "subreports" would have to be registered as new components
within a designer in order to be available for any end-user?

Am I o a correct way or are there any better solutions, maybe some
public available?

Tia Carsten

--


Hint: We altered the sources!Hint: We altered the sources!

Comments

  • edited February 2016
    Hi Carsten,

    A newer way to accomplish this is via the Design Layers feature. This is a
    really cool feature that enables any number of background layers to be added
    to a report layout. One nice thing is that, when you are working on the
    foreground layer, the objects in the background layer are not selectable, so
    they stay out of your way.

    For for standard header and footer, you could either use one background page
    layer that contains the header and footer elements or create separate layers
    for each.

    A background layer has a Template object property that be used to
    loaded/saved to file, just like a report/subreport.

    From the RBuilder Help topic for TppDesignLayer...

    Represents a named collection of components that implement a logical layer
    of a report layout, such as a background, water mark, form, grid pattern,
    etc.

    Every report layout always has a Foreground layer. To add a background layer
    select the Designer Layers node in the tree view. Next, press the right
    mouse button and select either New Page Layer or New Band Layer from the
    context menu. A tab set will appear just below the report tree and just
    above the object inspector. Use the tab set to select a design layer for
    editing.

    There are two layer types: PageLayer, BandLayer. PageLayer represents
    elements in a PageStyle band and BandLayer represents elements in bands.



    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2016
    Hi Nard,

    your idea for different pagelayers sounds good as it satifies our
    request for independent headers and footers. Our customers should be
    able to select in a set of headers and footers.

    Here are some more questions:
    - How do I define a layer to be a "background"-layer? I suppose it is
    done by "OrderIndex"
    - How should these backgroundlayers be loaded dynamically on runtime?
    Or is this implicitly done by setting template's properties for a layer
    within mainreport? Are there template properties for such layers or
    only for the foregroundlayer?
    - Can a templaterport for a background contain such backgroundlayers?
    - Can I setup a different layout for a first page compared to all
    following pages?

    Tia Carsten



    Nard Moseley (Digital Metaphors) schrieb am 15.02.2016 :

    --


    Hint: We altered the sources!Hint: We altered the sources!
  • edited February 2016
    Hi Carsten,

    Every report has a Foreground layer. Additional design layers are always
    background layers. The OrderIndex changes as layers are added. A new layer
    is assigned OrderIndex 0 (back most), the Foreground is always
    DesignLayers.Count-1 (top most). You can change the OrderIndex of layers,
    except for the Foreground layer - it is always top most.

    The Report.DesignerLayers.Add method can be used to programmatically add a
    layer. Report.DesignerLayers['layername'] and
    Report.DesignerLayers.ItemsByIndex[Index] provide access to DesignLayer
    items. (See RBuilder Help topic TppDesignLayers, TppDesignLayer)

    DesignLayer.Template property can be used to load a layer. (Layers are save
    to .ltm file).

    lDesignLayer.Template.FileName := 'myDesignLayer.ltm';
    lDesignLayer.Template.LoadFromFile;

    To use different background layers on various pages, you can use the
    Report.OnStartPage event to check the Report.AbsolutePageNo and set
    DesignLayer.Visible

    A DesignLayer is just a design concept, a way of managing/grouping a
    collection of elements into logical layers. The Report.Bands[ ].Objects[ ]
    still defines the report structure. Its just that an Object now has a
    DesignLayer property.






    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2016
    Hi Nard,

    your hints are very worthful.


    What is the difference between a Layerfile .ltm and a report .rtm?

    Thanks
    Carsten

    Nard Moseley (Digital Metaphors) schrieb am 16.02.2016 :

    --


    Hint: We altered the sources!Hint: We altered the sources!
  • edited February 2016

    The Report (.rtm) contains the report definition. For the report layout it
    contains the Report, Bands, Groups, Objects, DesignLayers, etc.

    The Layer (.ltm) contains the objects (Label, DBText, etc) for the layer.

    So if you have Report and want to load a background layer, you need to first
    add a layer to the report and then use Layer.Template to load the objects
    from the .ltm. After loading the .ltm the objects are now in the
    Report.Bands[].Objects[] structure of the report.

    A good way to get started is to use the Designer to create a few simple
    tests.



    Best regards,

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.