Discussions
Categories
Choose a Product
THRUST SERVICES
CORE APPS
CE PRODUCTS
...
Quick Links
POPULAR
HELPFUL TIPS
Groups
My Links
FOR SIGNED IN MEMBERS:
Back to website
Home
Designing Analytics Reports
Dynamic Table based off dynamic data set
Migrateduser
<p>Hey,</p>
<p> </p>
<p>We are using OS BIRT 4.2.2.</p>
<p> </p>
<p>I'm trying to make a report where we display the full data set result in a table. The data set SQL will be different depending on a report parameter.</p>
<p> </p>
<p>Currently I have the following.</p>
<p> </p>
<p><strong>Data Set - Before Open Script</strong></p>
<p>this.queryText = 'SELECT * FROM ' + params["rpTable"].value</p>
<p> </p>
<p><strong>Data Set - After Open Script</strong></p>
<p>importClass(org.eclipse.birt.report.engine.script.internal.instance.DataSetInstance);<br>
//Do not execute when dataset is previewed<br>
if( this instanceof DataSetInstance ){<br><br>
cmd = this.getColumnMetaData( );<br>
colCount = cmd.getColumnCount( );</p>
<p> </p>
<p>if (params["rpCounter"].value != colCount)<br>
{<br>
params["rpCounter"].value = colCount<br><br>
for ( i = 1; i <= colCount; i++ )<br>
{<br><br>
if (i < colCount) {<br>
params["rpColumn"].value = params["rpColumn"].value + cmd.getColumnName(i) + ',';<br>
} else if (i == colCount){<br>
params["rpColumn"].value = params["rpColumn"].value + cmd.getColumnName(i);<br>
}<br>
}<br>
}</p>
<p>}</p>
<p> </p>
<p><strong>Table - On Prepare Script</strong><br><br>
var columnList = params["rpColumn"].value. split(",");<br><br>
numColumns = params["rpCounter"].value;<br>
i=1;<br>
importPackage( Packages.org.eclipse.birt.report.model.api );<br>
elementFactory = reportContext.getDesignHandle().getElementFactory()<br>
var mytable = reportContext.getDesignHandle().findElement("test");<br>
var colbinds = mytable.getColumnBindings();<br>
var cs1 = []; StructureFactory.createComputedColumn();<br>
<br>
<br>
while (i <= numColumns){<br>
cs1
= StructureFactory.createComputedColumn( );<br>
cs1
.setName(columnList[i-1]);<br>
cs1
.setExpression( "dataSetRow[\"" + columnList[i-1] + "\"]" );<br>
colbinds.addItem( cs1
);<br>
<br>
//second parameter is before(-1) or after(1)<br>
mytable.insertColumn(i+1,-1);<br>
//get first detail row<br>
mydetail = mytable.getDetail( ).get( 0 );<br>
//get first column and add detail data item<br>
var tcell = mydetail.getCells( ).get( i );<br>
var mydata = elementFactory.newDataItem( null );<br>
mydata.setResultSetColumn( columnList[i-1]);<br>
tcell.getContent( ).add( mydata );<br>
//get header and add label<br>
var myheader = mytable.getHeader( ).get( 0 );<br>
tcell = myheader.getCells( ).get( i );<br>
var mylabel = elementFactory.newLabel( null );<br>
mylabel.setText( columnList[i-1] );//$NON-NLS-1$<br>
tcell.getContent( ).add( mylabel );<br>
i++;<br>
}<br>
</p>
<p> </p>
<p>This will work if I do a drill down to the same report keeping the parameters. (Basically a refresh of the page)</p>
<p> </p>
<p>The reason that I think this works with the refresh is because the table script does not have the data set data (param rpColumn) so it doesn't populate the table.</p>
<p> </p>
<p>So is there a better way to do this, or maybe a way to get the table script to get the data set data without a refresh, or a way to make the report refresh with parameters after it loads the first time?</p>
<p> </p>
<p>Thanks for any Help!</p>
Find more posts tagged with
Comments
There are no comments yet