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)
Adding table grouping at a runtime programmatically?
newbie321
<p>Hi,</p>
<p> </p>
<p>How do you add a table grouping at a runtime programmatically?</p>
<p> </p>
<p>below is the xml code equivalent for the table group, however I can not seem to replicate this .xml via java script. I am able to set expression via </p>
<pre class="_prettyXprint">
.setExprKey()</pre>
<p>. But how do I get to the cell (id=45) through script? Also, once I am at the cell level, do I just use </p>
<pre class="_prettyXprint">
.setProperty("resultSetColumn", "CITY")</pre>
<p><strong> </strong>method?<strong> </strong></p>
<p> </p>
<p>Thanks,</p>
<pre class="_prettyXprint _lang-">
<group id="34">
<property name="groupName">NewTableGroup1</property>
<property name="hideDetail">false</property>
<expression name="keyExpr" type="javascript">row["CITY"]</expression>
<header>
<row id="35">
<property name="backgroundColor">#400040</property>
<property name="color">#FFFF80</property>
<cell id="36">
<data id="45">
<property name="resultSetColumn">CITY</property>
</data>
</cell>
<cell id="37"/>
<cell id="38"/>
<cell id="39"/>
</row>
</header>
<footer>
<row id="40">
<cell id="41"/>
<cell id="42"/>
<cell id="43"/>
<cell id="44"/>
</row>
</footer>
</group>
</pre>
Find more posts tagged with
Comments
JFreeman
<p>You can add a table group by creating a TableGroupHandle and then adding it to the table using the addElement method of the TableHandle.</p>
<p> </p>
<p>For example:</p>
<pre class="_prettyXprint _lang-js">
var myTableGroup = reportContext.getDesignHandle().getElementFactory().newTableGroup();
myTableGroup.setKeyExpr("row[\"STATUS\"]");
myTableGroup.setInterval("none");
myTableGroup.setSortDirection("asc");
var myTable = reportContext.getDesignHandle().getElementByID(9);
myTable.addElement(myTableGroup, org.eclipse.birt.report.model.api.TableHandle.GROUP_SLOT);
</pre>
<p>Take a look at the attached report design with this code in place for reference.</p>
newbie321
<p>Thanks, #JFreeman!! </p>
<p> </p>
<p>This sure does the trick.
</p>
<p> </p>
<p>On a related topic, how to I create the following XML grouping structure (header for the group) through javascript?</p>
<p> </p>
<div>
<pre class="_prettyXprint">
<header>
<row id="35">
<property name="backgroundColor">#400040</property>
<property name="color">#FFFF80</property>
<cell id="36">
<data id="45">
<property name="resultSetColumn">CITY</property>
</data>
</cell>
<cell id="37"/>
<cell id="38"/>
<cell id="39"/>
</row>
</header></pre>
<p>Thanks!!</p>
</div>
JFreeman
<p>You're welcome.</p>
<p> </p>
<p>To make sure I am understanding, you want to dynamically add a group header to the same table after adding the grouping dynamically?</p>
newbie321
<p>Hi, #JFreeman;</p>
<p> </p>
<p>yes that is correct - group header to a table group. Essentially I would like to replicate programmatically (javaScript or java) the following XML code:</p>
<p> </p>
<div>
<pre class="_prettyXprint">
<group id="34">
<property name="groupName">NewTableGroup1</property>
<property name="hideDetail">false</property>
<expression name="keyExpr" type="javascript">row["CITY"]</expression>
<structure name="toc">
<expression name="expressionValue" type="javascript">row["CITY"]</expression>
</structure>
<header>
<row id="35">
<property name="backgroundColor">#400040</property>
<property name="color">#FFFF80</property>
<cell id="36">
<data id="45">
<property name="resultSetColumn">CITY</property>
</data>
</cell>
<cell id="37"/>
<cell id="38"/>
<cell id="39"/>
</row>
</header>
<footer>
<row id="40">
<cell id="41"/>
<cell id="42"/>
<cell id="43"/>
<cell id="44"/>
</row>
</footer>
</group></pre>
<p>Thanks!! </p>
</div>
JFreeman
<p>Take a look at this old post I just dug up: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/25112-how-to-define-group-property-using-birt-design-engine-api/?p=98576'>http://developer.actuate.com/community/forum/index.php?/topic/25112-how-to-define-group-property-using-birt-design-engine-api/?p=98576</a></p>
;
<p> </p>
<p>I believe that covers what you are needing.</p>
<p>It is using the Design Engine API in Java but it should be fairly easy to adapt to javascript to use inside the report design instead.</p>
newbie321
<p>Thanks,
@JFreeman
!! </p>
<p> </p>
<p>The solution worked like a charm. </p>
<p> </p>
<p>Much appreciated!</p>
JFreeman
<p>You're welcome.</p>
<p>I'm happy to be of assistance.</p>
<p> </p>
<p>Let us know if you have additional questions.</p>