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)
Spacing between data groups in report
femibyte
Hi, can someone provide an example as to how I can create group and create extra spacing between rows in a report using the Java Report Design API ? <br />
<br />
Hence if I currently have a table that looks like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>col1 col2 col3
A X 1
A X 1
B Y 2
B Y 2
C Z 3
C Z 3</pre>
<br />
I'd like it to instead look like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>col1 col2 col3
A X 1
A X 1
B Y 2
B Y 2
C Z 3
C Z 3</pre>
<br />
Frankly, I am a bit confused as to how the TableGroup API works.<br />
<br />
Thanks for your help.
Find more posts tagged with
Comments
mwilliams
Take a look at this code. It shows how to grab the table, create a group, add a group footer, and set a height for the group footer, so you get your spacing. Commented out are lines of code that will add a group header and add a data element to the first cell that contains the group value. Hope this helps.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
//get element factory
elementFactory = reportContext.getDesignHandle().getElementFactory();
//get table handle
th = reportContext.getDesignHandle().findElement("myTable");
//create table group
tableGroup = elementFactory.newTableGroup();
tableGroup.setName("col1Group");
tableGroup.setKeyExpr("row[\"col1\"]");
//add group to table
th.getGroups().add(tableGroup);
//create group header/footer rows and group data element and add to group
//groupHeader = elementFactory.newTableRow(3);
groupFooter = elementFactory.newTableRow(3);
//ghCell = groupHeader.getCells().get(0);
//ghData = elementFactory.newDataItem(null);
//ghData.setResultSetColumn("col1");
//ghCell.getContent().add(ghData);
groupFooter.getHeight().setAbsolute(.25);
//tableGroup.getHeader().add(groupHeader);
tableGroup.getFooter().add(groupFooter);
</pre>
<br />
This code should go in the beforeFactory script of the report and the table should be named "myTable"
femibyte
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="106937" data-time="1341503546" data-date="05 July 2012 - 08:52 AM"><p>
Take a look at this code. It shows how to grab the table, create a group, add a group footer, and set a height for the group footer, so you get your spacing. Commented out are lines of code that will add a group header and add a data element to the first cell that contains the group value. Hope this helps.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
//get element factory
elementFactory = reportContext.getDesignHandle().getElementFactory();
//get table handle
th = reportContext.getDesignHandle().findElement("myTable");
//create table group
tableGroup = elementFactory.newTableGroup();
tableGroup.setName("col1Group");
tableGroup.setKeyExpr("row[\"col1\"]");
//add group to table
th.getGroups().add(tableGroup);
//create group header/footer rows and group data element and add to group
//groupHeader = elementFactory.newTableRow(3);
groupFooter = elementFactory.newTableRow(3);
//ghCell = groupHeader.getCells().get(0);
//ghData = elementFactory.newDataItem(null);
//ghData.setResultSetColumn("col1");
//ghCell.getContent().add(ghData);
groupFooter.getHeight().setAbsolute(.25);
//tableGroup.getHeader().add(groupHeader);
tableGroup.getFooter().add(groupFooter);
</pre></p></blockquote>
<br />
You're really the BIRT guru ^_^ Thanks a lot.
mwilliams
Not a problem!