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)
Creating one grid per data row with a dynamic number of columns?
wiscdev
<p>Hello,<br />
<br />
I am trying to migrate a PDF report from one project to another. The old project uses iText 1.3. The new project uses Eclipse BIRT 2.4. I am new to BIRT so I apologize in advance if my use of terminology is off.<br />
<br />
The format of the old report looks like a small table per row from the database query. I was thinking that I might be able to put a grid per datarow in the XML .rpt file and pass the contents of the grid as datarow parameters. I have the skeleton for this converted report set up as a ScriptedDataSetEventAdapter, based on the format of the other BIRT report in the project.</p><p> </p><p>However, there is a wrinkle in this problem. The small table can have a variable number of rows. Let's say my report is a list of shoes.:</p><p> </p><p>Datarow 1:</p><p>[font="'courier new', courier, monospace;"] Inventory per size[/font]</p><p>[font="'courier new', courier, monospace;"]Item 123. Lovely Oxfords. 7 8 9 10 [/font]</p><p>[font="'courier new', courier, monospace;"] 1 2 2 0[/font]</p><p> </p><p>Datarow 2:</p><p> [font="'courier new', courier, monospace;"]Inventory per size[/font]</p><p>[font="'courier new', courier, monospace;"]Item 456 European Clogs 37 38 39 40 41[/font]</p><p>[font="'courier new', courier, monospace;"] 1 3 3 2 1[/font]</p><p> </p><p>[font="arial, helvetica, sans-serif;"]As you can see, the number of the "size" columns as well as the titles of these columns can be totally different depending on the row. I'd like to reuse the data retrieval code from the old report, and I have this data available as Java POJOs, built from a database query. Is it possible for me to dynamically build a BIRT grid for each datarow and pass it to the report? Is this a good approach to take to this problem?[/font]</p><p> </p><p>[font="arial, helvetica, sans-serif;"]Thanks for any insight.[/font]</p><p> </p>
Find more posts tagged with
Comments
wiscdev
<p>I went ahead and coded a solution according to the above plan and I'm stuck on an error.</p><p> </p><p> </p><p>In my Java code I have:</p><p> </p><div><pre class="_prettyXprint">GridHandle grid = null;grid = createGrid();if (grid == null) { return false; }row.setColumnValue("ItemGrid", grid);</pre></div><div> </div><div>where createGrid is a method I wrote which is dynamically adding rows and columns to a grid to satisfy the problem I outlined in the previous post.</div><div> </div><div>In my XML .rpt template file I have </div><div> </div><div><pre class="_prettyXprint"> <row id="13"> <cell id="14"> <data id="19"> <property name="paddingTop">6pt</property> <property name="paddingBottom">6pt</property> <property name="textAlign">center</property> <property name="resultSetColumn">ItemGrid</property> </data> </cell> </row></pre><p>The error I get is:</p><p> </p><p>SEVERE: Line Number:20 Error Code:Error.XMLParserException.EXCEPTION Exception:org.eclipse.birt.report.model.api.metadata.PropertyValueException: The choice value "org.eclipse.birt.report.model.api.GridHandle" is not found. Message:A generic exception occurred.</p><p> </p><p>I suspect that this means that I cannot insert a gridhandle directly into this cell according to the XML schema. Is that right? Is there a minor adjustment I need to make this work, such as a wrapper tag, or have I gone down the wrong path?</p><p> </p><p>Thanks</p><p> </p></div>
wiscdev
<p>In the end, it looks like this solution doesn't work for me. I've abandoned the event handler approach and am building the grids and adding them to the report in a simple for loop. Since the framework for this is simpler, I'm not sure why the other BIRT report already existing in my project doesn't do the same.</p><p> </p><p>In any case, I found a workable solution.</p>
mwilliams
<p>Glad you found something that works. If this solution ends up not working for some reason, let me know and we can try to work on another solution.</p>
Tamanna Sharma
<blockquote class="ipsBlockquote" data-author="mwilliams" data-cid="121756" data-time="1383594375">
<div>
<p>Glad you found something that works. If this solution ends up not working for some reason, let me know and we can try to work on another solution.</p>
</div>
</blockquote>
<p>Hi Williams,</p>
<p> </p>
<p>I am working on a similar scenario. I am also new to Birt Reporting.</p>
<p>Please let us know that :</p>
<p>1. is there any way to associate multiple dataset to one crosstab?</p>
<p>2. Scenario is to display number of charts on a report and this number depends upon the output of a query. </p>
<p> </p>
<p>Please let us know what would be the efficient way to implement the scenario 2.</p>
<p> </p>
<p>Thanks..</p>
<p>Thanks...</p>
shamo
<p>you can union the 2 data sets to get 1 for creating your data cube.</p>
Tamanna Sharma
<blockquote class="ipsBlockquote" data-author="shamo" data-cid="139924" data-time="1446141571">
<div>
<p>you can union the 2 data sets to get 1 for creating your data cube.</p>
</div>
</blockquote>
<p>Thanks..</p>
<p> </p>
<p>One issue is still there.</p>
<p> </p>
<p>I am unable to set the number of rows/columns of a grid at runtime using the count of result by a query.</p>
<p>So first, the query will execute, then count of the resultset is taken and then number of rows/columns is set on the count.</p>
<p> </p>
<p>Thanks for the help!!</p>