Page 1 of 1
Drop Elements Depending on Output Format
Posted by
mwilliams
, 08 March 2013 - 06:34 PM
Sometimes when designing a report, you want to only show certain elements in certain output formats. Not just hide them, but actually drop them, so the bound dataSet doesn't run or for saved processing time. Say you want to drop a certain element from your report when you run your report to the XLS output. To do this, you'd simply name your report element in the property editor, then put the following in your beforeFactory script:
This works as you would expect, for most outputs. However, when you try this for pdf, while it does drop the correct element when you run the report in pdf, it also drops the element when you run the report in the web viewer. This is because getOutputFormat returns pdf when you run your report with the web viewer.
Luckily, there is a way around this. You also have access to the HttpServletRequest, so if you use a script like the following, in your beforeFactory, the correct format will be returned.
With this method, we now see that the web viewer is actually HTML and the correct element is dropped from the report.
This solution will only work in open-source BIRT, as the HttpServletRequest is not available in the commercial version. The sample report used in this post can be downloaded here.
if(reportContext.getOutputFormat() == "xls"){
reportContext.getDesignHandle().findElement("elementName").drop();
}
This works as you would expect, for most outputs. However, when you try this for pdf, while it does drop the correct element when you run the report in pdf, it also drops the element when you run the report in the web viewer. This is because getOutputFormat returns pdf when you run your report with the web viewer.
Luckily, there is a way around this. You also have access to the HttpServletRequest, so if you use a script like the following, in your beforeFactory, the correct format will be returned.
if(reportContext.getHttpServletRequest().getAttribute("attributeBean").format == "pdf"){
reportContext.getDesignHandle().findElement("elementName").drop();
}
With this method, we now see that the web viewer is actually HTML and the correct element is dropped from the report.
This solution will only work in open-source BIRT, as the HttpServletRequest is not available in the commercial version. The sample report used in this post can be downloaded here.
Last week in the Forums: Calling a Function in BIRT Script Area from HTML Button, Localization in Chart Not Working, and more...
Posted by
mwilliams
, 23 January 2012 - 08:20 AM
This blog series takes a look back at the past week in the forums, recalling how active they were and highlights some of the questions asked that seem to frequent the forums or other interesting topics. The site was down for maintenance much of this past week and Monday was a holiday, so the traffic was pretty slow. Still, many great questions and answers were posted. As always, thanks to those users who help answer questions! It is a great help to the community!
Last week's unanswered post was how to use a HTML button to call a function from the report script. The poster wanted to be able to use script in a HTML button to call a function that is declared in their report's initialize script. They know they can create a function within the HTML to call, but wanted to know if they could do this with a function within the BIRT script methods. If anyone has done this or has a suggestion. Please post in the thread!
The next topic I'll cover from last week is datetime localization not working in charts. The poster noticed an issue in 2.5.1 that their localization didn't affect their axis labels in their chart. In a newer version, 2.6.2, it did work. The issue ended up being that setting a format code in the chart wizard messed up the localization. The workaround solution was to apply the formatting in script. The necessary script is shown in the thread.
The last topic I'll cover is about where to find the new features for the latest release. This question gets asked often enough that I thought it would be a good one to cover. To find the newest features, the best place to look is at the project plan pages for BIRT on eclipse.org. You should be able to find all versions and what new features went in to each. You can also find the bugs that were addressed with each version.
Again, this is just a small sample of what went through the forums this past week. For more questions and answers that have been posted, check out the forums. As always, if you have a question, feel free to ask it, and if you see a question you know the answer to or have a similar experience to, feel free to post an answer or comment.
Last week's unanswered post was how to use a HTML button to call a function from the report script. The poster wanted to be able to use script in a HTML button to call a function that is declared in their report's initialize script. They know they can create a function within the HTML to call, but wanted to know if they could do this with a function within the BIRT script methods. If anyone has done this or has a suggestion. Please post in the thread!
The next topic I'll cover from last week is datetime localization not working in charts. The poster noticed an issue in 2.5.1 that their localization didn't affect their axis labels in their chart. In a newer version, 2.6.2, it did work. The issue ended up being that setting a format code in the chart wizard messed up the localization. The workaround solution was to apply the formatting in script. The necessary script is shown in the thread.
The last topic I'll cover is about where to find the new features for the latest release. This question gets asked often enough that I thought it would be a good one to cover. To find the newest features, the best place to look is at the project plan pages for BIRT on eclipse.org. You should be able to find all versions and what new features went in to each. You can also find the bugs that were addressed with each version.
Again, this is just a small sample of what went through the forums this past week. For more questions and answers that have been posted, check out the forums. As always, if you have a question, feel free to ask it, and if you see a question you know the answer to or have a similar experience to, feel free to post an answer or comment.
Page 1 of 1
Recent Entries
Plug In 2 BIRT Contest - Spring 2013 Ends Soon
Creating Derived Cube Measures and More with BIRT and ActuateOne
Drop Elements Depending on Output Format
Solving a TOC Bookmark Issue by Using Multiple Fields in a Single Group Expression
Visualizing the Impact of Database Changes with BIRT and ActuateOne
Actuate's 11SP4 Release Provides Many Powerful New Capabilities, Including HTML5 Charts and more!
Getting a Marker in the Middle of a Gantt Chart Bar, Multi-Level HTML List Numbering, and more...
Switch to a Default Table if no Values Returned in Query, Parameterize the From Portion of an SQL Query, and more...
Adding Text to an Image, Using Table Data for a Crosstab's Data, and more...
Only Highlight Bars of a Certain Series in a Chart, Reordering a Table's Columns, and more...
Creating Derived Cube Measures and More with BIRT and ActuateOne
Drop Elements Depending on Output Format
Solving a TOC Bookmark Issue by Using Multiple Fields in a Single Group Expression
Visualizing the Impact of Database Changes with BIRT and ActuateOne
Actuate's 11SP4 Release Provides Many Powerful New Capabilities, Including HTML5 Charts and more!
Getting a Marker in the Middle of a Gantt Chart Bar, Multi-Level HTML List Numbering, and more...
Switch to a Default Table if no Values Returned in Query, Parameterize the From Portion of an SQL Query, and more...
Adding Text to an Image, Using Table Data for a Crosstab's Data, and more...
Only Highlight Bars of a Certain Series in a Chart, Reordering a Table's Columns, and more...
My Blog Links
Recent Comments
- mwilliams on Creating a BIRT report as a calendar view
- lnallamalli on Creating a BIRT report as a calendar view
- For Birt on Last Week in the Forums: BIRT and R Statistical Language, Specified Sort Order for a Table, and more...
- Bhanwar on Last Week in the Forums: Filtering Blank Spaces from Distinct Count Aggregation, Adding a Line at 0 in a Chart with Negative Values, and more...
- Srividya Sharma on Sorting a Crosstab by a Field Not Displayed in the Crosstab
- mwilliams on Last Week in the Forums: Using the Concatenate Aggregate, Hiding a Column When There is No Data, and more...
- java032 on Last Week in the Forums: Using the Concatenate Aggregate, Hiding a Column When There is No Data, and more...
- java032 on Last Week in the Forums: Using the Concatenate Aggregate, Hiding a Column When There is No Data, and more...
- java032 on Last Week in the Forums: Using the Concatenate Aggregate, Hiding a Column When There is No Data, and more...
0 user(s) viewing
0 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)
Categories
- .rptdocument
- 11 SP4
- Actuate
- ActuateJavaComponent
- ActuateOne
- aggregating data
- aggregation
- alignment issues
- Alternating Highlight
- archived BIRT versions
- area chart
- axis label
- barcodes
- batch file
- BDPro
- BIRT
- BIRT Exchange
- BIRT functions
- BIRT Studio
- BIRT-Exchange
- bookmarks
- border
- border color
- bursting
- calendar
- cascading parameter
- CEAPI
- cell border
- chart
- charting
- charts
- color
- color codes
- command line
- computed column
- connection profile
- contest
- crosstab
- CSS
- CSV
- CSV export
- custom group
- custom sort
- Data Analyzer
- data cube
- Data Object
- data point label spacing
- data row security
- data set filter
- data set parameters
- dataset parameters
- Date Format
- deapi
- deploy
- devShare
- display name
- drop
- drop series
- dynamic chart
- dynamic chart labels
- dynamic chart marker
- dynamic chart scale
- dynamic chart title
- dynamic column sort
- Dynamic Column Visibility
- dynamic data set
- dynamic grid content
- dynamic grouping
- dynamic labels
- dynamic min/max
- dynamic scale
- Dynamic Text
- Dynamic Width
- Eclipse
- elapsed time format
- embedded grid
- empty csv error
- Event Handlers
- exception handling
- export data
- expression builder
- filter
- Firefox
- flash map
- Forum
- Forums
- fragmented schema
- gantt
- gantt chart
- global function
- GMT date
- grids
- group numbering
- grouping
- hide label
- hide measure detail
- hide series
- Hierarchy
- hierarchy report
- highlight
- highlight negative numbers
- HTML
- HTML listbox
- html lists
- HTML select form
- HTML Table
- HTML5
- https
- hyperlink
- image
- Impact Analysis
- Import Elements
- Ineractive Viewer
- Information Objects
- Interactive Viewer
- invalid dates
- iServer
- JAX-WS
- joint data set
- jquery
- jsapi
- JSF
- JSP
- legend
- legend color
- Library
- line height
- locale
- localization
- marker range color
- master page
- masterpage
- Maximo
- merge data
- multi-line text
- multi-select parameter
- multi-select parameters
- multi-value parameter
- multiple series
- NetWeaver
- newspaper
- newspaper layout
- optional y-series grouping
- osgi
- overlaying elements
- page break
- parameter
- parameters
- parameters in query
- PDF Complete
- Perl
- Pie Chart
- plug-in
- postgresql encoding issue
- progress bar
- property file
- R Statistical Language
- refresh report
- relative path
- reorder table
- report engine
- report viewer title
- reporting
- Reports
- Rolling Sum
- rotated text
- rptdesign
- rptlibrary
- runtime
- scatter plot
- script
- scripted dataset
- scroll bars
- Seam
- secure connection
- series color
- series name
- session variable
- sort
- Sort Order
- SP4
- special characters
- SQL
- SQL injection
- stacked bar
- stored procedure
- Styles
- Sub Report
- summing values from two different elements
- SVG
- table
- table footer
- Themes
- TOC
- TOC with page numbers
- tomcat
- Tooltip
- transient report cache
- truncated text
- user parameters
- Vaadin
- value-of format
- version features
- Viewer
- viewer title
- visibility
- Web Service
- web viewer
- Webshpere
- Word
- xls
- XML data source


