Hitachi Vantara Pentaho Community Forums
Results 1 to 7 of 7

Thread: style expression/formula language

  1. #1
    Join Date
    May 2009
    Posts
    7

    Default style expression/formula language

    Hi,
    I'm trying to create a table of contents for my report.
    For that I need labels that are visible dependent on whether the appropriate subreport is empty (and not visible) or not empty (and visible).
    I was trying something like
    Code:
    visible:=If([Element@959170.visible]="true";"true";"false")
    but that doesn't work.
    Any idea?
    Greets

  2. #2
    Join Date
    Apr 2007
    Posts
    2,009

    Default

    you need to lose the quotes.

    try something like:

    visible:=If([Element@959170.visible]=TRUE;TRUE();FALSE())
    Not sure if you need the () on the if side of the TRUE too! experiment with it and see...

    In fact, i think you can dump the =TRUE so it looks like this:

    visible:=If([Element@959170.visible];TRUE();FALSE())

  3. #3
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    I assume that "Element@959170.visible" is the name of an other formula, expression, parameter or column of your dataset. Otherwise, you wont hae any luck with that field-name. You cannot reference report-elements from within a expression or formula.

    Our formula language is a implementation of the OpenFormula standard, which can be found here:
    http://www.oasis-open.org/committees...office-formula

    A short version can be found in our Wiki:
    http://wiki.pentaho.com/display/Repo...la+Expressions
    or even as sticky reference on top of the forum:
    http://forums.pentaho.org/showthread.php?t=65283
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  4. #4
    Join Date
    May 2009
    Posts
    7

    Default

    I hoped I could ask for the state (visible or not) of Element@12345678 (which is a subreport) by handling the style expression "visible" as an attribute of it.

    So I tried
    Code:
                  visible := If( [Element@1234].visible=TRUE(); TRUE(); FALSE() )
              or visible := If( [Element@1234.visible]=TRUE(); TRUE(); FALSE() )
              or visible := If( [Element@1234]=visible; TRUE(); FALSE() )
    But if I got you right, that's not possible.
    Right?

  5. #5
    Join Date
    Oct 2007
    Posts
    235

    Default

    your best bet is probably to use the same logic as what ever you are doing to show/hide the sub report. if the sub report is visible =IF(a=2;TRUE();FALSE()) then put the same thing in for your table of contents element.

  6. #6
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    No, you cant ask for the state of an element, as the state will not be known until alter all other expressions have been run. We do not implement a large scale DOM for reports, as this would make our report-processing as slow as a typical browser's rendering.

    If you're using PRD-3.0 or earlier, then subreports do not have a visiblity control - they always run.

    If I would want to collect the headings of subreports, I would do it via an own function placed on the master-report. The function must return true on the "isDeepTraversing" method - this causes it to receive all events from all the subreports. Then all you have to do is to wait for "reportStarted" events to flow in and to extract your data.

    Then instead of dropping the data into a tablemodel/own subreport - which is impossible thanks to some limitations in the engine - I would simply modify the master-report#s report-header to add labels as needed to build a table-of-contents. The labels and placeholders should be in place after the function ran for the first time.

    (@see ReportEvent#getLevel(); 0 for building the header, -1 for filling in page-numbers, as -1 is the pagination-run, so you will receive page-events as well)
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  7. #7
    Join Date
    May 2009
    Posts
    7

    Default

    Well....thanks for your quick replies.

    I found another easy way to do it, using the SingleValueQueryFunction to check if the first field of the subreport is empty or not; and on this condition it is decided if the TOC-label to appropriate subreport is visible or not.
    Numbering will be difficult, but...

    Best regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.