Home
Analytics
Expand and collapse functionality
vince20151.birt
<p>Is there a way to expand or collapse a detail section in a BIRT report?</p><p> </p><p>I have a report showing at the break group level Employee Name and ID. Then the detail for Employee (like time card lines) are shown underneath. I'm looking to implement the functionality where you can click on a link (or plus sign) on the employee header row to expand the time card section. And toggle by clicking on a link (or minus sign) to collapse. Similar to an explorer type of navigation.</p><p> </p><p>I know BIRT has the table of content (TOC) but this is more like an index rather than interactive expand/collapse functionality in the report content itself.</p>
Find more posts tagged with
Comments
vince20151.birt
<p>Having this post for 2 weeks without any response, I guess there is no simple solution for this. Hoping that this would get into BIRT future enhancements. For now, I settle with drill down which really open another report instead of in line expand/collapse.</p>
kclark
<p>Instead of using a drill through to do this you could use the data engine api in the initilize() of your report doing something like this</p><pre class="_prettyXprint">var customernumber = new java.util.ArrayList();var checknumber = new java.util.ArrayList();var paymentdate = new java.util.ArrayList();var amount = new java.util.ArrayList();importPackage( Packages.org.eclipse.birt.report.model.api );importPackage(Packages.java.lang);importPackage(Packages.java.util);importPackage(Packages.org.eclipse.birt.data.engine.api);importPackage(Packages.org.eclipse.birt.report.model.api);importPackage(Packages.org.eclipse.birt.data.engine.api.querydefn);importPackage(Packages.org.eclipse.birt.data.engine.core);importPackage(Packages.org.eclipse.birt.core.data);var myconfig = reportContext.getReportRunnable().getReportEngine().getConfig();var de = DataEngine.newDataEngine( myconfig, null );var dsrc = reportContext.getDesignHandle().findDataSource("Data Source");var dset = reportContext.getDesignHandle().findDataSet("Data Set");var odaDataSource = new OdaDataSourceDesign( "Test Data Source" );odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );odaDataSource.addPublicProperty( "odaURL", dsrc.getProperty("odaURL").toString() );odaDataSource.addPublicProperty( "odaDriverClass", dsrc.getProperty("odaDriverClass").toString());odaDataSource.addPublicProperty( "odaUser", dsrc.getProperty("odaUser").toString() );odaDataSource.addPublicProperty( "odaPassword", "" ); var odaDataSet = new OdaDataSetDesign( "Test Data Set" );odaDataSet.setDataSource( odaDataSource.getName( ) );odaDataSet.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );odaDataSet.setQueryText( dset.getQueryText() ); de.defineDataSource( odaDataSource );de.defineDataSet( odaDataSet );queryDefinition = new QueryDefinition( );queryDefinition.setDataSetName( odaDataSet.getName() );queryDefinition.setAutoBinding(true);var pq = de.prepare( queryDefinition );var qr = pq.execute( null );ri = qr.getResultIterator( );while(ri.next()) { customernumber.add(ri.getValue("CUSTOMERNUMBER")); checknumber.add(ri.getValue("CHECKNUMBER")); paymentdate.add(ri.getValue("PAYMENTDATE")); amount.add(ri.getValue("AMOUNT"));}reportContext.setPersistentGlobalVariable("customernumber", customernumber);reportContext.setPersistentGlobalVariable("checknumber", checknumber);reportContext.setPersistentGlobalVariable("paymentdate", paymentdate);reportContext.setPersistentGlobalVariable("amount", amount);</pre><p>At the end it stores all the values in ArrayList's and set's them as PGV's. You can the call back these values in the onCreate() of a text item and build an html table with some script that allows you to expand/collapse the rows. I know that commercial BIRT has a feature like this out of the box too. I haven't tried this solution yet but if you're ok with building the table from script then this should work.</p>
BRM
This is one of the most frequently requested report interactions. You might have a look at the following.<br> <br><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/426-expandablecollapsible-groups-by-drill-through/'>Expandable/Collapsible
Groups by Drill Through</a><br><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/29854-hyperlinking-the-data-between-tables-in-a-page/'>Hyperlinking
the Data between Tables in a Page</a><br><a data-ipb='nomediaparse' href='
http://www.ibm.com/developerworks/data/library/techarticle/dm-0708tomlyn/'>http://www.ibm.com/developerworks/data/library/techarticle/dm-0708tomlyn/</a><br> <br>There
are other resources and examples out there that can be found with a little searching.
anshul9824
<p>Hi everyone,</p>
<p> </p>
<p>Can anyone provide me sample birt report having expand/collapse button. I have a report with 102 columns, i want to add a expand/collapse button so that can i show some columns with their data, and then after clicking on button the further columns get displayed with their data.</p>
anshul9824
<p>Then.. Can anyone tell me how to create a table in a birt report using javascript? </p>
mwilliams
<p>So, you want to show how to expand and collapse column sections?</p>
anshul9824
<p>Hi Michael,</p>
<p> </p>
<p>Yes... i have created a report with a collapse/expand button through drill down hyperlinking method. But this is not a good way as i have to create several sub reports. My requirement is that to have a collapse/expand button so that user can collapse columns which he didn't want to see. Now i want to create a create a table using javascript so that i can use ajax for hide/show button feature. So, please tell me how to create a table in birt using javascript.</p>
<p>Thanks for your reply.</p>
mwilliams
When you say sub reports, are you talking about embedded tables within your single design? Or multiple designs to drill to? If multiple designs, you should be able to achieve all of this with a single design.<br><br>Are you using the paginated viewer? Or are you using the straight html output? With straight html, it'd be much easier to do all of this as you wouldn't have to deal with the separate pages in the viewer.<br><br>If you want to dynamically create a table within BIRT, you have to do it in the beforeFactory method, which would require you to rerun the report.
anshul9824
<p>Hi Michael,</p>
<p> </p>
<p>Through sub reports I would like to say different reports of the groups of column on which i want to apply collapse/expand feature. However I have used <span style="color:rgb(37,37,37);font-family:sans-serif;">simple work-around method of hyperlink by pasting a +/- image in the upper right hand side of the main reports table. and then referencing these images to the other reports of different column sections.</span></p>
<p><span style="color:rgb(37,37,37);font-family:sans-serif;">Anyways thanks for looking into my problem.</span></p>
<p> </p>
<p><span style="color:rgb(37,37,37);font-family:sans-serif;">Thank you..</span></p>
mwilliams
Glad you found something to work for you. Let us know whenever you have questions.
parubagavathi92@gmail.com
<p>Hello,</p>
<p> </p>
<p>I am trying to use the expand and collapse option in the PRD tool in anyone type of report(CSV/HTML/PDF). Like in my report output there should be a "plus symbol" or "hyperlink" to expand a table/section in the report which the user wants to see and collapse it if not need, Can you please assist me with a generic code which would help to achieve this.</p>
<p> </p>
<p>Thanks in advance!</p>