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)
Use dataSet value in label in a grid cell with the Design Engine API
urabirt
<p>Hi,</p>
<p> </p>
<p>I'm very new to BIRT. I am generating a report by programming in full Java, using the Design Engine API. I would like to build a label, whose text would be retrieved from a dataset. For instance, my label (LabelHandle) would display an address, and I would retrieve this address from a dataSet, having a column "address". I need this label to be simply contained in a cell inside of grid, not inside of a table. I have successfully retrieved data from my dataSet in tables, but simply displaying it in a label, I have googled a lot and haven't found how to perform this apparently simple thing.</p>
<p> </p>
<p>Thanks a lot for your help!</p>
Find more posts tagged with
Comments
Matthew L.
<p>Here is a simple example I have found to create a Label in a Grid cell:</p>
<p><a data-ipb='nomediaparse' href='
https://eclipse.org/birt/resources/documentation/integrating/DeDemo.java'>https://eclipse.org/birt/resources/documentation/integrating/DeDemo.java</a></p>
;
<pre class="_prettyXprint">
//Code snip from: https://eclipse.org/birt/resources/documentation/integrating/DeDemo.java
LabelHandle label = factory.newLabel( null );
cell = (CellHandle) row.getCells( ).get( 0 );
cell.getContent( ).add( label );
label.setText( "Hello, world!" ); //$NON-NLS-1$
</pre>
urabirt
<p>Thanks for the reply, but actually, instead of row text "Hello, world!", I need to set the label's text from a dataSource.</p>
<p> </p>
<p>The idea is to be able to do something like that:</p>
<p>label.setText(myDataSource.getString("address"));</p>
<p> </p>
<p> </p>
<p>Any idea how to perform this? I'm currently using the OdaDataSetHandle type but can't find a way to get the actual values contained in dataset, coming from database.</p>
<p> </p>
<p> </p>
<p>Thanks again for helping!</p>
Matthew L.
<p>It sounds like you are wanting a data element (DataItemHandle).</p>
<p>You can bind the DataSetHandle to the Grid element and use the DataItemHandle to display the values.</p>
<p>An example of this for a table is here: <a data-ipb='nomediaparse' href='
http://code.google.com/p/birtdemo/source/browse/trunk/project/DEAPI+Webinar/deapiwebinar/APIs/src/DEAPI/ScriptedDS.java'>http://code.google.com/p/birtdemo/source/browse/trunk/project/DEAPI+Webinar/deapiwebinar/APIs/src/DEAPI/ScriptedDS.java</a></p>
;
<p>However, since you are using a Grid element, I would change the binding to use the Grid instead of a Table element.</p>
<p> </p>
<p>Another option would be to Iterate through the data set and either dynamically build your Grid, or output the values to an array which you can then call in your Label elements.</p>
<p>I don't have a Java example however, an example of this from within the reports JavaScripting might be helpful: <a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369'>http://developer.actuate.com/community/forum/index.php?/topic/35930-running-a-query-in-the-initalize/?p=133369</a></p>
;
urabirt
<p>The example with scripted dataset is close to what I need. I tested with my own jdbc dataset, and when I try to retrieve the resultSet columns, I get a null object for resultSetCols:</p>
<p> </p>
<p>DataSetHandle </p>
<p>dataSetHandle = (DataSetHandle) design.getDataSets().get(0);</p>
<p>List<?> </p>
<p>resultSetCols = dataSetHandle.getListProperty(OdaDataSetHandle.<b><i>RESULT_SET_PROP</i></b>);</p>
<p> </p>
<p> </p>
<p>For an OdaDataSetHandle, how this RESULT_SET_PROP property must be set?</p>
<p> </p>
<p>Thanks a lot, your input is very helpful</p>
urabirt
<p>Evenutally, I got it working, as I could hard code the column names in my case.</p>
<p> </p>
<p>Again, thanks, you made my day
</p>