Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Dynamic Report - Sorting Columns
chocba
Hi,
I've a report in which the table is created at runtime when 'before factory' event is fired. I do have a 'beforeRender' event handler where I'm trying to sort table using a parameter. The parameter will specify which column to sort and direction. In 'before Render' event, I've the following code:
importPackage( Packages.org.eclipse.birt.report.model.api );
sortKey = StructureFactory.createSortKey();
sortKey.setKey("row["" + "0" + ""]");
sortKey.setDirection("asc");
tbl = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("myNewTable")
sortProps = tbl.getPropertyHandle("sort");
sortProps.addItem(sortKey);
I hardcoded the key as "0" and sort direction for testing. For some reason, if I've the key value as 0, sorting works fine and table is sorted by 1st column. If I change the value to 1 or 2, to sort table by other columns, BIRT is complaining with an error message 'Fail to compute value from sort, group or filter expression. Invalid bound column name: 1"
My assumption is when 'before Render' event is fired, the table "myNewTable" is already available. If it can sort table for key value "0" why not for other columns. Given that table is created and binded when 'before factory' event is fired, should I sort the table when 'before Render' event is fired or some where else? Appreciate your help. I've attached the rptdesign file if you need to look at it. Thanks.
Find more posts tagged with
Comments
JustME
I used the following method to create a sortable table. I posted the example to the devshare at:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/devshare/designing-birt-reports/1124-drill-down-report-with-sortable-tables/#description'>Drill
Down Report with Sortable Tables - Designs & Code - BIRT Exchange</a><br />
<br />
It's not exactly what you are trying to do, but it does create sortable tables. Let me know if this helps.