Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Label to span multiple cells/columns of table header
femibyte
Hi, how do I get a label to span multiple columns of a table header in the BIRT design API ?<br />
<br />
For example I want to do somethinglike this:<br />
<br />
<br />
<strong class='bbc'><pre class='_prettyXprint _lang-auto _linenums:0'>DataTitle DateColumns
colHdr1 colHdr2 colHdr3 colHdr4 date1 date2 date3 date4</pre></strong><br />
<br />
<br />
Thus there are 2 rows in the header.<br />
<br />
For simplicity sake I defined the header to have 2 rows with 8 columns corr. to the <br />
no. of columns in the 2nd header row.<br />
<br />
But I'd like DateColumns to span columns 5-6 and not get squeezed into column 5.<br />
<br />
Here's the code snippet I am using:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>for (int idx=0;idx<rowTexts.size();idx++)
{
RowText rowText=rowTexts.get(idx);
System.out.println("RowText=" + rowText);
LabelHandle label = elementFactory.newLabel("Label" + idx);
int startColNum=rowText.getStartColNum();
int colSpan=rowText.getColSpan();
String text=rowText.getText();
label.setText(text);
System.out.println("LBL Text=" + text);
CellHandle cell = (CellHandle) tblHdrRow.getCells().get(startColNum);
cell.setColumnSpan(colSpan);
cell.getContent().add(label);
}
</pre>
<br />
However this produces an invalid .rptdesign file.<br />
<br />
Any help would be greatly appreciated.
Find more posts tagged with
Comments
femibyte
<blockquote class='ipsBlockquote' data-author="'femibyte'" data-cid="107006" data-time="1341602785" data-date="06 July 2012 - 12:26 PM"><p>
Hi, how do I get a label to span multiple columns of a table header in the BIRT design API ?<br />
<br />
For example I want to do somethinglike this:<br />
<br />
<br />
<strong class='bbc'><pre class='_prettyXprint _lang-auto _linenums:0'>DataTitle DateColumns
colHdr1 colHdr2 colHdr3 colHdr4 date1 date2 date3 date4</pre></strong><br />
<br />
<br />
Thus there are 2 rows in the header.<br />
<br />
For simplicity sake I defined the header to have 2 rows with 8 columns corr. to the <br />
no. of columns in the 2nd header row.<br />
<br />
But I'd like DateColumns to span columns 5-6 and not get squeezed into column 5.<br />
<br />
Here's the code snippet I am using:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>for (int idx=0;idx<rowTexts.size();idx++)
{
RowText rowText=rowTexts.get(idx);
System.out.println("RowText=" + rowText);
LabelHandle label = elementFactory.newLabel("Label" + idx);
int startColNum=rowText.getStartColNum();
int colSpan=rowText.getColSpan();
String text=rowText.getText();
label.setText(text);
System.out.println("LBL Text=" + text);
CellHandle cell = (CellHandle) tblHdrRow.getCells().get(startColNum);
cell.setColumnSpan(colSpan);
cell.getContent().add(label);
}
</pre>
<br />
However this produces an invalid .rptdesign file.<br />
<br />
Any help would be greatly appreciated.<br /></p></blockquote>
<br />
<br />
Never mind, I found out the solution here: <a class='bbc_url' href='
http://www.eclipse.org/forums/index.php/m/363752/'>http://www.eclipse.org/forums/index.php/m/363752/</a><br
/>
<br />
It turns out that I have to drop the columns to be spanned, then do the column span, like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>tblHdrRow.getCells( ).get( 2).drop();
tblHdrRow.getCells( ).get( 3).drop();
tblHdrRow.getCells( ).get( 1).setColumnSpan(3);
</pre>
vijayshankar245
<blockquote class="ipsBlockquote" data-author="femibyte" data-cid="107009" data-time="1341607442">
<div>
<p>
Never mind, I found out the solution here: <a class="bbc_url" href="
http://www.eclipse.org/forums/index.php/m/363752/">http://www.eclipse.org/forums/index.php/m/363752/</a><br><br>
;
It turns out that I have to drop the columns to be spanned, then do the column span, like this:<br>
</p>
<pre class="_prettyXprint _lang-auto _linenums:0">
tblHdrRow.getCells( ).get( 2).drop();
tblHdrRow.getCells( ).get( 3).drop();
tblHdrRow.getCells( ).get( 1).setColumnSpan(3);
</pre>
</div>
</blockquote>
<p>Hi</p>
<p> </p>
<p>Anyone kindly let me know where did you write this code snippet in the report? Im also looking for the similar code for my report to group a couple of columns in my table to a single label.</p>