Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
URGENT -- Conditional table header
jyol2005
Hi!
I've been struggling with this one and I need some help here.
Is there a way to have two header rows (with some of the column header labels different in each header) and display these conditionally for each group. For example, I have a table with a group (let's say by Country). I would like to show group header 1 if the country == USA and 2 for everything else.
I created the table with two header rows and a group with page break after each group and have set the visibility property on each of the header rows to check for the above condition. First page (with country = USA) seems to be using the correct header and the second page has the group for some other country, this is where it doesn't seem to work.
Also, is there a way to suppress the group footer (totals) if there's only one row in the group? How do I check the row count for each group?
Thanks.
Find more posts tagged with
Comments
bhanley
The issue is that you have correctly set the logic to do the initial visibility calculation (for the first group) but the problem is that the logic you have implemented is never re-visited.
Having set the page break to fire on each group, modify the onCreate script for the group header row to evaluate the value in country to see if you want to change the row's visibility for that group.
jyol2005
I'm not sure how I do this. It's not a group header I am talking about, but the table header row (where we display column headers). I have two of these as the column headers are different depending on the country.
Are you asking me to create something like following for the onCreate script of each of the table header rows? The following would need a name for the table header row and I don't see in the properties editor to give a name for the header row.
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
delm = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("COUNTRYHEADER");
hr = StructureFactory.createHideRule();
hr.setFormat("html");
hr.setExpression("if( row["Country"] == 'USA' ){true;}else{false;}");
ph = delm.getPropertyHandle("visibility");
ph.addItem(hr);
bhanley
Sorry if I mis-read your issue. So you are having the table header re-applyed after each page break. And you would like to change the table header row based on a rule. This is actually easier than changing the Group Header.
Have you tried adding the show/hide logic to the afterPageBreak scripting event for the table? You should be able to get what you are looking for there.
jyol2005
Can you please let me know how I add the afterPageBreak scripting event for the table?
jyol2005
I'm still searching how to conditionally switch between the two table headers. Anybody can help with this?
bhanley
I have spent a great deal of time trying to work up a sample report that does this for you but I have not had any luck. I am looking at how the report is constructed at view time and it looks like the header row is cached to be re-used at each page break. That is why it is not re-evaluating the visibility criteria.
In answer to your post above, the way to apply a name to a row element (or any other BIRT report element) is to add a string to the Bookmark property.
I will keep noodling on this, but as things stand right now I am a bit stuck.