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)
deleting column
kosta
Hello BIRT community, <br />
<br />
how can I delete column from the table in run-time using the API without errors?<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
...
TableHandle table = (TableHandle) designHandle.findElement("table");
table.getColumns().get(0).drop();
...
</pre>
<br />
or via for-loop with the getColumnCount().<br />
<br />
I can delete the columns from the table but the design after saving it to a rptdesign file gives errors (inconsistent column count) because the headers and details and the data binding still are there.<br />
<br />
Thanks in advance for any suggestions.
Find more posts tagged with
Comments
JasonW
Kosta,
Clear the row cells first.
TableHandle th = (TableHandle)report.findElement("mytable");
RowHandle header = (RowHandle) th.getHeader( ).get( 0 );
header.getCells().get(0).drop();
RowHandle detail1 = (RowHandle) th.getDetail().get( 0 );
detail1.getCells().get(0).drop();
RowHandle footer = (RowHandle) th.getFooter( ).get( 0 );
footer.getCells().get(0).drop();
th.getColumns().get(0).drop();
Jason
kosta
Hi Jason,<br />
<br />
I tried this one and it work.<br />
But when the table has group I was using something like:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
TableGroupHandle tgh = (TableGroupHandle)table.getGroups().get(0);
RowHandle header = (RowHandle)tgh.getHeader().get(0);
CellHandle tcell = (CellHandle) header.getCells( ).get( 0 );
tcell .drop()
</pre>
<br />
I can see that the group cell is dropped but the group head appears in new column.<br />
<br />
Have I missed something?<br />
<br />
Thanks in advance.
kosta
I made an example rptdesign file for this case:
JasonW
Kosta,
Is there something wrong with the example you posted? It seems to work for me.
Jason
kosta
Hi Jason,<br />
<br />
the first state of the table is:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
empty header | product code | product name | empty
empty group header | empty | empty | product line group
empty detail | product code | product name | quantity stock
</pre>
after the operation the table looks like:<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
product code | product name | empty | empty
empty | empty | empty | product line group
product code | product name | quantity stock | empty
</pre>
<br />
I have expected <br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
product code | product name | empty
empty | empty | product line group
product code | product name | quantity stock
</pre>
<br />
Why the group output is still in the 4th column and not above the "quantity stock" in the third? The 4th column shouldn't exist any more. :blink:<br />
<br />
Thanks for any suggestion.
JasonW
you did not drop that cell. Do this:
var tgh = mytable.getGroups().get(0);
var header = tgh.getHeader().get(0);
var tcell = header.getCells( ).get(0);
tcell.drop();
Jason
kosta
Thanks a lot, I wonder how could I forget that.
Hosein
<blockquote class='ipsBlockquote' data-author="'JasonW'" data-cid="74877" data-time="1300746860" data-date="21 March 2011 - 03:34 PM"><p>
you did not drop that cell. Do this:<br />
var tgh = mytable.getGroups().get(0);<br />
var header = tgh.getHeader().get(0);<br />
var tcell = header.getCells( ).get(0);<br />
tcell.drop();<br />
<br />
Jason<br /></p></blockquote>
<br />
Hi <br />
How can i drop second or third column ? above code only drops first column , i changed 0 to 1 but no column deleted. <br />
<br />
Thanks in advance <br />
S.M.H.Jamali
kosta
Hi Hosein,
it depends how your table is build.
You must delete all cells that are bound to that column,
and at the end you can delete the column itself.
The real fun begins when you have colspans and rowspans.
Then to find the real cell's is a little bit tricky.
Beside dropping you must modify some of the other cells.
It depends how your table is build.
Cheers.