Search code examples
expressionbirt

Dynamic text in master page of Birt report


Can dynamic text be entered into a header or footer of a master page?

I have placed dynamic text into a grid which then sits in the master page footer, this doesn't work and gives error:

ReportDesign (id = 1):
+ Invalid javascript expression: ReferenceError: "row" is not defined. (<inline>#1)

When I test the expression in the footer of the report layout itself this works.

Please see the expression below:

if( BirtComp.lessOrEqual( row["Aggregation"], "1,500.00" )){"user1.jpg"} 
else if (BirtComp.greaterThan(row["Aggregation"], "1,500.00")){ "user2.jpg"}

Solution

  • The easiest way to use dynamic text in the master page is as follows:

    • Optional, but recommended: Create a dataset "MasterPage" which selects the dynamic data that you need.

    • Create a grid in the page footer (and/or header) of the master page.

    • Bind the grid to the dataset "MasterPage".

    • Use dynamic text items and data items inside the grid as you like.

    Important:

    • The grid uses only the first row returned by your dataset.

    • Thus, it is best practice to create the dataset in such a way that it will return exactly one row.

    • This means that BIRT aggregation functions won't work here.

    • If your "MasterPage" dataset is JDBC based, you can of course use SQL aggregation functions like SUM, COUNT etc.

    • It is not possible to access "the current first record for the current page" this way: The "MasterPage" dataset returns one record for the whole report.