Adding detail row in a table using DE

akk2
akk2 Member
edited February 11, 2022 in Analytics #1
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!

Comments

  • mwilliams
    mwilliams Member
    edited December 31, 1969 #2
    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 ipb
  • akk2
    akk2 Member
    edited July 8, 2011 #3
    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! :)
  • mwilliams
    mwilliams Member
    edited December 31, 1969 #4
    You're welcome. Let us know whenever you have questions! :)
    Warning No formatter is installed for the format ipb
  • <p>Hello, I also having the same problem, but I'm trying to add new rows to existing GRID which already have n rows. It gave me same error stated in first post.</p>
  • <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>