Adding detail row in a table using DE
So I'm trying to implement dynamic reports. (using Birt 2.6.2) I have a saved report on disk which contains a table containing X number of row details, and I'm trying to edit the table to add more row details.<br />
<br />
I've found a thread with an example: <a class='bbc_url' href='http://www.birt-exchange.org/org/forum/index.php/topic/16624-how-to-add-a-detail-row-to-tablehandle/#post53870'>http://www.birt-exchange.org/org/forum/index.php/topic/16624-how-to-add-a-detail-row-to-tablehandle/#post53870</a><br />
<blockquote class='ipsBlockquote' ><p>rowParm = new RowOperationParameters(2, -1, 1);<br />
table.insertRow(rowParm);<br /></p></blockquote>
<br />
but when I try it, I get different exceptions depending on the RowOptionParameters parameters. <br />
<br />
My table has 1 (empty) detail row. <br />
<br />
I do: table.insertRow(new RowOperationParameters(1, -1, 0));:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>org.eclipse.birt.report.model.api.command.ContentException: The Row is not allowed in the slot (Groups) of Table("myTable").<br />
at org.eclipse.birt.report.model.util.ContentExceptionFactory.createContentException(ContentExceptionFactory.java:43)<br />
at org.eclipse.birt.report.model.command.AbstractContentCommand.checkBeforeAdd(AbstractContentCommand.java:188)<br />
at org.eclipse.birt.report.model.command.ContentCommand.checkBeforeAdd(ContentCommand.java:164)<br />
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(AbstractContentCommand.java:149)<br />
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:152)<br />
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:102)<br />
at org.eclipse.birt.report.model.api.SlotHandle.paste(SlotHandle.java:222)<br />
at org.eclipse.birt.report.model.api.RowBandInsertAction.doInsert(RowBandInsertAction.java:113)<br />
at org.eclipse.birt.report.model.api.TableHandle.insertRow(TableHandle.java:442)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:540)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span><br />
</em><br />
<br />
<br />
I do: table.insertRow(new RowOperationParameters(1, -1, 1));:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>org.eclipse.birt.report.model.api.elements.SemanticError: The insert operation on the element "myTable" is forbidden.<br />
at org.eclipse.birt.report.model.api.RowBandInsertAction.doInsert(RowBandInsertAction.java:101)<br />
at org.eclipse.birt.report.model.api.TableHandle.insertRow(TableHandle.java:442)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:540)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span></em><br />
<br />
The slotId param seems to be fine because if I replace it with a 0 or 2, I get Array out of bounds exceptions:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>java.lang.IndexOutOfBoundsException: Index: 1, Size: 1<br />
at java.util.ArrayList.RangeCheck(Unknown Source)<br />
at java.util.ArrayList.get(Unknown Source)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:542)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span></em><br />
<br />
<br />
I've seen another topic with the same error, but this isn't at runtime at all... Any idea of what could be wrong? I can add columns to the table, but I can't seem to be able to add row details...<br />
<br />
Thanks!
<br />
I've found a thread with an example: <a class='bbc_url' href='http://www.birt-exchange.org/org/forum/index.php/topic/16624-how-to-add-a-detail-row-to-tablehandle/#post53870'>http://www.birt-exchange.org/org/forum/index.php/topic/16624-how-to-add-a-detail-row-to-tablehandle/#post53870</a><br />
<blockquote class='ipsBlockquote' ><p>rowParm = new RowOperationParameters(2, -1, 1);<br />
table.insertRow(rowParm);<br /></p></blockquote>
<br />
but when I try it, I get different exceptions depending on the RowOptionParameters parameters. <br />
<br />
My table has 1 (empty) detail row. <br />
<br />
I do: table.insertRow(new RowOperationParameters(1, -1, 0));:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>org.eclipse.birt.report.model.api.command.ContentException: The Row is not allowed in the slot (Groups) of Table("myTable").<br />
at org.eclipse.birt.report.model.util.ContentExceptionFactory.createContentException(ContentExceptionFactory.java:43)<br />
at org.eclipse.birt.report.model.command.AbstractContentCommand.checkBeforeAdd(AbstractContentCommand.java:188)<br />
at org.eclipse.birt.report.model.command.ContentCommand.checkBeforeAdd(ContentCommand.java:164)<br />
at org.eclipse.birt.report.model.command.AbstractContentCommand.add(AbstractContentCommand.java:149)<br />
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:152)<br />
at org.eclipse.birt.report.model.api.SlotHandle.add(SlotHandle.java:102)<br />
at org.eclipse.birt.report.model.api.SlotHandle.paste(SlotHandle.java:222)<br />
at org.eclipse.birt.report.model.api.RowBandInsertAction.doInsert(RowBandInsertAction.java:113)<br />
at org.eclipse.birt.report.model.api.TableHandle.insertRow(TableHandle.java:442)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:540)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span><br />
</em><br />
<br />
<br />
I do: table.insertRow(new RowOperationParameters(1, -1, 1));:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>org.eclipse.birt.report.model.api.elements.SemanticError: The insert operation on the element "myTable" is forbidden.<br />
at org.eclipse.birt.report.model.api.RowBandInsertAction.doInsert(RowBandInsertAction.java:101)<br />
at org.eclipse.birt.report.model.api.TableHandle.insertRow(TableHandle.java:442)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:540)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span></em><br />
<br />
The slotId param seems to be fine because if I replace it with a 0 or 2, I get Array out of bounds exceptions:<br />
<br />
<em class='bbc'><span style='font-size: 8px;'>java.lang.IndexOutOfBoundsException: Index: 1, Size: 1<br />
at java.util.ArrayList.RangeCheck(Unknown Source)<br />
at java.util.ArrayList.get(Unknown Source)<br />
at x.BirtReportManager.updateTableInfoReport(BirtReportManager.java:542)<br />
at x.BirtReportManager.updateReport(BirtReportManager.java:238)<br />
at x.BirtReportManager.main(BirtReportManager.java:118)</span></em><br />
<br />
<br />
I've seen another topic with the same error, but this isn't at runtime at all... Any idea of what could be wrong? I can add columns to the table, but I can't seem to be able to add row details...<br />
<br />
Thanks!
0
Comments
-
Does (2,-1,1) not work for you if you have just one detail row? When you add a detail row, you need to do (2,-1,destination) where destination is the 0 based row number. So, if you have a row already, you add one with 1 as destination because 0 is already filled. If you have 2 already, you use 2, etc. The second number is the group, so if you're not adding a row to the group, you use -1 for no value. I think that's how it works.Warning No formatter is installed for the format ipb0
-
Ah! Yes it works actually (Btw, the Array out of bounds exceptions I mentioned above with slotId = 2 happened later in my code so wasn't a Birt issue... :\)<br />
<br />
A small loop experiment: <br />
<span style='font-size: 8px;'>Trying RowOperationParameters(0, -1, 0)<br />
Worked! Table detail count = 1<br />
Trying RowOperationParameters(0, -1, 1)<br />
Worked! Table detail count = 1<br />
Trying RowOperationParameters(0, -1, 2)<br />
Worked! Table detail count = 1<br />
Trying RowOperationParameters(1, -1, 0)<br />
Exception = The Row is not allowed in the slot (Groups) of Table("mytable").<br />
Trying RowOperationParameters(1, -1, 1)<br />
Exception = The insert operation on the element "mytable" is forbidden.<br />
Trying RowOperationParameters(1, -1, 2)<br />
Exception = The insert operation on the element "mytable" is forbidden.<br />
Trying RowOperationParameters(2, -1, 0)<br />
Worked! Table detail count = 2<br />
Trying RowOperationParameters(2, -1, 1)<br />
Worked! Table detail count = 3<br />
Trying RowOperationParameters(2, -1, 2)<br />
Worked! Table detail count = 4</span><br />
<br />
<br />
So it's effectively like you said. I was under the impression that the slotId also needed to be incremented but yeah, slotId = 0 doesn't seem to insert anything in detail, 1 throws exceptions and 2 works <br />
<br />
Ah, just stumbled on the src of RowOperationParameters, this info could have been in the API...<br />
<br />
/**<br />
* slot id. When group id is smaller than zero , slot id stands for<br />
* group header, or SLOT_GROUP_FOOTER; else slot id stands for<br />
* SLOT_TABLE_HEADER , SLOT_TABLE_DETAIL , SLOT_TABLE_FOOTER<br />
* <br />
*/<br />
private int slotId;<br />
<br />
So the 2 is from a constant, not sure where it is located though... TableHandle(IListingElementModel) has DETAIL_SLOT (value 2), HEADER_SLOT (value 0), etc. but those probably aren't the same... Hmm... I should probably download the entire source...<br />
<br />
Thanks for your help!0 -
<p>is it possible to add only n records by calling an api to a table and then use a button (next n) to fetch next n records and then repopulate the table ? Also will grouping/sorting apply be applicable then ?</p>0
Categories
- All Categories
- 122 Developer Announcements
- 53 Articles
- 151 General Questions
- 146 Thrust Services
- 56 OpenText Hackathon
- 35 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 917 Cloud Fax and Notifications
- 84 Digital Asset Management
- 9.4K Documentum
- 31 eDOCS
- 179 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 9 XM Fax
- Follow Categories