Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Cascading parameters default value(Select default value of the cascading parameter as first row returned by the DataSet query)
Cascading parameters default value [message #529921] Tue, 27 April 2010 16:59 Go to next message
Fane Prapad is currently offline Fane PrapadFriend
Messages: 7
Registered: April 2010
Junior Member
I have a Cascading Parameter Group with 2 combo-boxes that are populated by two DataSet queries. The second combo-box depends on the value selected in the first combo-box.

I have 2 problems with the 2nd combo-box:
1. I can not get rid of the "Null value" option in the list of values
2. After the value for first combo-box has been selected and the query populating the 2nd combo-box returns its results, I would like to set the default value of the combo-box, as the first row returned by the associated query. Currently, the default value is <empty> (<option></option>), not even "null value"

Is it possible to set the default value of the 2nd combo-box, at runtime? if yes, can I set it to one of the values returned by its associated query?
Or may I create a list(it can be even static) of possible default values and at runtime the report can chose the first matching value?

[Updated on: Tue, 27 April 2010 17:02]

Report message to a moderator

Re: Cascading parameters default value [message #530421 is a reply to message #529921] Thu, 29 April 2010 15:33 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Fane

Can you switch to list box instead of combo? Setting the default value
can be done by implementing the getDefaultValueList script for the
parameter. The only issue with this is that to get the list from the
current dataset you will need to open some type of connection to the
datasource and get the values. You should be able to create a jdbc
connect to it and return the list. I have an example of calling a birt
dataset using the Data Engine API, but this API is likely to change so
you might not want to use it. I am attaching the report.

Jason


<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="layoutPreference">auto layout</property>
<property name="bidiLayoutOrientation">ltr</property>
<parameters>
<scalar-parameter name="ListParameter3" id="21">
<property name="valueType">dynamic</property>
<property name="dataSetName">tiedtolist3</property>
<expression name="valueExpr"
type="javascript">dataSetRow["ORDERNUMBER"]</expression >
<expression
name="sortByColumn">dataSetRow["ORDERNUMBER"]</expression >
<property name="sortDirection">asc</property>
<property name="dataType">integer</property>
<property name="distinct">true</property>
<property name="paramType">multi-value</property>
<property name="controlType">list-box</property>
<property name="mustMatch">true</property>
<property name="fixedOrder">false</property>
<method name="getDefaultValueList"><![CDATA[//var dVLArray
= [];
//dVLArray[0]= "10104";
//dVLArray[1] = "10108";
//dVLArray;



importPackage(Packages.java.io);

try{

rsArr= [];

importPackage(Packages.java.lang);
importPackage(Packages.java.util);
importPackage(Packages.org.eclipse.birt.data.engine.api);
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.data.engine.api.quer ydefn);
importPackage(Packages.org.eclipse.birt.data.engine.core);


var myconfig =
reportContext.getReportRunnable().getReportEngine().getConfi g();
var de = DataEngine.newDataEngine( myconfig, null );

var dsrc = reportContext.getDesignHandle().findDataSource("Data Source");
var dset = reportContext.getDesignHandle().findDataSet("tiedtolist3");

var odaDataSource = new OdaDataSourceDesign( "Test Data Source" );
odaDataSource.setExtensionID( "org.eclipse.birt.report.data.oda.jdbc" );
odaDataSource.addPublicProperty( "odaURL",
dsrc.getProperty("odaURL").toString() );
odaDataSource.addPublicProperty( "odaDriverClass",
dsrc.getProperty("odaDriverClass").toString());
odaDataSource.addPublicProperty( "odaUser",
dsrc.getProperty("odaUser").toString() );
odaDataSource.addPublicProperty( "odaPassword", "" );

//odaDataSource.addPublicProperty( "odaURL",
"jdbc:classicmodels:sampledb" );
//sourceHandle.getProperty("odaURL").toString() );
//odaDataSource.addPublicProperty( "odaDriverClass",
"org.eclipse.birt.report.data.oda.sampledb.Driver");//sourceHandle.getProperty( "odaDriverClass").toString());
//odaDataSource.addPublicProperty( "odaUser", "ClassicModels"
);//sourceHandle.getProperty("odaUser").toString() );
//odaDataSource.addPublicProperty( "odaPassword", "" );



var odaDataSet = new OdaDataSetDesign( "Test Data Set" );
odaDataSet.setDataSource( odaDataSource.getName( ) );
odaDataSet.setExtensionID(
"org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" );
odaDataSet.setQueryText( dset.getQueryText() );
//odaDataSet.setQueryText( "Select ORDERNUMBER from orders"
);//dsh.getQueryText() );


de.defineDataSource( odaDataSource );
de.defineDataSet( odaDataSet );

queryDefinition = new QueryDefinition( );
queryDefinition.setDataSetName( odaDataSet.getName() );
queryDefinition.setAutoBinding(true);


var pq = de.prepare( queryDefinition );

var qr = pq.execute( null );


var ri = qr.getResultIterator( );
var cc = ri.getResultMetaData().getColumnCount();
var rsmd = ri.getResultMetaData();
var jj = 0;

while ( ri.next( ) )
{
//for ( i = 0; i < cc; i++ ){
rsArr[jj] = ri.getValue(rsmd.getColumnName(1)).toString();
//}
jj++;
}

ri.close( );
qr.close( );
de.shutdown( );
}catch(e){
}
rsArr;]]></method>
<structure name="format">
<property name="category">Unformatted</property>
</structure>
</scalar-parameter>
</parameters>
<data-sources>
<oda-data-source
extensionID="org.eclipse.birt.report.data.oda.jdbc" name="Data Source"
id="7">
<list-property name="privateDriverProperties">
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
</list-property>
<property
name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver </property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet "
name="tiedtolist3" id="22">
<list-property name="columnHints">
<structure>
<property name="columnName">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
</structure>
<structure>
<property name="columnName">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
</structure>
<structure>
<property name="columnName">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
</structure>
<structure>
<property name="columnName">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
</structure>
<structure>
<property name="columnName">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="dataType">float</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">ORDERNUMBER</property>
<property name="nativeName">ORDERNUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="nativeName">PRODUCTCODE</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="nativeName">QUANTITYORDERED</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="nativeName">PRICEEACH</property>
<property name="dataType">float</property>
<property name="nativeDataType">8</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="nativeName">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
<property name="nativeDataType">5</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from orderdetails]]></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERNUMBER</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERNUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERNUMBER</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRODUCTCODE</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRODUCTCODE</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRODUCTCODE</design:label>
<design:formattingHints>
<design:displaySize>15</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>QUANTITYORDERED</design:name>
<design:position>3</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>10</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>QUANTITYORDERED</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>QUANTITYORDERED</design:label>
<design:formattingHints>
<design:displaySize>11</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>PRICEEACH</design:name>
<design:position>4</design:position>
<design:nativeDataTypeCode>8</design:nativeDataTypeCode>
<design:precision>15</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PRICEEACH</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PRICEEACH</design:label>
<design:formattingHints>
<design:displaySize>22</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>ORDERLINENUMBER</design:name>
<design:position>5</design:position>
<design:nativeDataTypeCode>5</design:nativeDataTypeCode>
<design:precision>5</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>ORDERLINENUMBER</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>ORDERLINENUMBER</design:label>
<design:formattingHints>
<design:displaySize>6</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">"Verdana"</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab-cell" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
</report>


On 4/27/2010 12:59 PM, Fane Prapad wrote:
> I have a Cascading Parameter Group with 2 combo-boxes that are populated
> by two DataSet queries. The second combo-box depends on the value
> selected in the first combo-box.
>
> I have 2 problems with the 2nd combo-box:
> 1. I can not get rid of the "Null value" option in the list of values
> 2. After the value for first combo-box has been selected and the query
> populating the 2nd combo-box returns its results, I would like to set
> the default value of the combo-box, as the first row returned by the
> associated query. Currently, the default value is <empty>
> (<option></option>), not even "null value"
>
> Is it possible to set the default value of the 2nd combo-box, at
> runtime? if yes, can I set it to one of the values returned by its
> associated query?
Re: Cascading parameters default value [message #531616 is a reply to message #530421] Wed, 05 May 2010 15:24 Go to previous message
Fane Prapad is currently offline Fane PrapadFriend
Messages: 7
Registered: April 2010
Junior Member
Hey Jason,

Thanks allot for the example. It requires quite some work to set this default value...
If the API is going to change in the future, then it is not my best option. I will search for some alternatives...

Previous Topic:Fatal error occurred when try to startup report engine
Next Topic:SQL Query Builder missing
Goto Forum:
  


Current Time: Fri Apr 26 13:28:30 GMT 2024

Powered by FUDForum. Page generated in 0.03256 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top