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)
Grouping data on column that is not displayed
femibyte
Hi, I am using the Java Design Report API to generate my report design file.<br />
<br />
I would like to be able to group data on a column that is not displayed in the report. How can I do this?<br />
<br />
I have the following code below that groups data on an column that is in the report currently:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
// Table Group
TableGroupHandle group = elementFactory.newTableGroup( );
group.setName("group_colGroup");
group.setKeyExpr( "dataSetRow[\"group_col\"]" ); // just for Servicer
group.setInterval("none");
group.setSortDirection(DesignChoiceConstants.SORT_DIRECTION_ASC);
group.setRepeatHeader(true);
dataTable.getGroups().add(group);
RowHandle grpHdrHandle = elementFactory.newTableRow(dataCols.size());
CellHandle tblCellHandle = (CellHandle) grpHdrHandle.getCells().get(0);
//tblCellHandle.setDrop(DesignChoiceConstants.DROP_TYPE_DETAIL); // just for servicer
DataItemHandle data0 = elementFactory.newDataItem(null);
data0.setResultSetColumn("group_col"); // should be config property !!
tblCellHandle.getContent().add(data0);
group.getHeader().add(grpHdrHandle);
RowHandle groupFooter = elementFactory.newTableRow( dataCols.size() );
String groupFooterPadding=repMetaData.getDataGroupPadding();
groupFooter.getHeight().setStringValue(groupFooterPadding); // should be config property !!
group.getFooter().add(groupFooter);
</pre>
<br />
How can I modify this code if I don't wish to display the group_col column in my report ?<br />
<br />
Thanks for any help in advance
Find more posts tagged with
Comments
femibyte
The code above produces this exception:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>The column binding for the data "Table("dataTable").Groups[0].Header[0].Cells[0].Content[0]" with
column name "group_col" is not defined. Report.rptdesign
...
org.eclipse.birt.report.engine.api.EngineException: Fail to compute value from sort, group or filter expression.
Invalid field name: group_col.
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1199)
at org.eclipse.birt.report.engine.executor.ExecutionContext.addException(ExecutionContext.java:1178)
at org.eclipse.birt.report.engine.executor.QueryItemExecutor.executeQuery(QueryItemExecutor.java:96)
at org.eclipse.birt.report.engine.executor.TableItemExecutor.execute(TableItemExecutor.java:62)
at org.eclipse.birt.report.engine.internal.executor.dup.SuppressDuplicateItemExecutor.execute(SuppressDuplicateItemExecutor.java:43)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportItemExecutor.execute(WrappedReportItemExecutor.java:46)
at org.eclipse.birt.report.engine.internal.executor.l18n.LocalizedReportItemExecutor.execute(LocalizedReportItemExecutor.java:34)
</pre>
mwilliams
You should be able to add the field as a binding to the table without displaying it. Then, you could use it as the field to group the table on.
femibyte
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="109998" data-time="1348867900" data-date="28 September 2012 - 02:31 PM"><p>
You should be able to add the field as a binding to the table without displaying it. Then, you could use it as the field to group the table on.<br /></p></blockquote>
<br />
Do you have any Java Design API code example I could take a look at that does this?
mwilliams
I don't have an example handy, but I could make one, if necessary. What you just need to make sure is that the binding you're trying to group on exists in the table's bindings. To get the group value not to display, all you need to do is not put the data element in the group header. The binding has to be in the table's bindings though, in case that was misunderstood.