| Detect No Data condition in Scripted data source [message #254630] |
Thu, 06 September 2007 10:07  |
Eclipse User |
|
|
|
Originally posted by: vencat.b.gmail.com
Hi,
I want to detect "No Data" condition in scripted data source and display
appropriate message "No Data exists for your parameter selection" instead of
chart or table in report. How do i do this?
I tried to use count in open/fetch method and check if its 0, but after this
is executed there did not seem any way to prevent chart/table being
rendered. If i supress the chart / table then open/fetch method is not
executed.
Thanks
|
|
|
|
|
|
|
| Re: Detect No Data condition in Scripted data source [message #255069 is a reply to message #254956] |
Tue, 11 September 2007 11:39  |
Eclipse User |
|
|
|
Originally posted by: jasonweathersby.alltel.net
Venc,
You are correct about the data sets being executed twice. This should
get fixed in 2.2.1. I like your approach much better. Thanks for
posting it.
Jason
venc wrote:
> Thanks jason. This is my solution:
>
> a) Create a hidden parameter NoData which is boolean and set to false by
> default
> b) In fetch method
> [if( i >= params["myrows"] ){
> if(i==0) params["NoData"]=true;
> return false;
> }else{
> row.mydata = i;
> i++
> return true;
> }
>
> And then created suppression formula: if(params["NoData")==true) { false; }
> else { true; }
>
> I might be wrong but the problem with your approach is binding same dataset
> to two different tables might cause scripted datasource to be executed
> twice. I havent tested this but thats my hunch. But your approach definitely
> helped me in right direction.
>
> Many thanks as always for frequently responding to our questions in this
> forum.
>
>
> "Jason Weathersby" <jasonweathersby@alltel.net> wrote in message
> news:fc4hb8$1dt$2@build.eclipse.org...
>> Venc,
>>
>> I apologize. I did this in 2.2. You should be able to build an aggregate
>> using the Total functions in earlier versions.
>>
>> Jason
>>
>> venc wrote:
>>> Jason,
>>> Does this work in 2.1.2 or 2.1.3? I tested your file but i get No Data
>>> message all the time. Did not seem to work in 2.1.3. Is is possible the
>>> aggregation is introduced in 2.2.x?
>>>
>>> Thank you very much for responding to newsgroup queries.
>>> -venkat
>>>
>>>
>>> "Jason Weathersby" <jasonweathersby@alltel.net> wrote in message
>>> news:fc3ngc$t0k$1@build.eclipse.org...
>>>> Venc,
>>>>
>>>> There are a lot of ways to do this. You can add an aggregation to the
>>>> table that uses the scripted ds that counts the rows and use the
>>>> visibility feature. Take a look at this example.
>>>>
>>>> Jason
>>>>
>>>> <?xml version="1.0" encoding="UTF-8"?>
>>>> <report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.14"
>>>> id="1">
>>>> <property name="createdBy">Eclipse BIRT Designer Version
>>>> 2.2.0.v20070620 Build <2.2.0.v20070626-1003></property>
>>>> <property name="units">in</property>
>>>> <property name="comments">Copyright (c) 2007 <<Your Company
>>>> Name here>></property>
>>>> <html-property name="description">Creates a blank report with no
>>>> predefined content.</html-property>
>>>> <text-property name="displayName">Blank Report</text-property>
>>>> <property name="iconFile">/templates/blank_report.gif</property>
>>>> <parameters>
>>>> <scalar-parameter name="myrows" id="8">
>>>> <property name="valueType">static</property>
>>>> <property name="dataType">decimal</property>
>>>> <property name="controlType">text-box</property>
>>>> <property name="defaultValue">5</property>
>>>> <structure name="format">
>>>> <property name="category">Unformatted</property>
>>>> </structure>
>>>> </scalar-parameter>
>>>> </parameters>
>>>> <data-sources>
>>>> <script-data-source name="Data Source" id="6"/>
>>>> </data-sources>
>>>> <data-sets>
>>>> <script-data-set name="Data Set" id="7">
>>>> <list-property name="resultSetHints">
>>>> <structure>
>>>> <property name="position">0</property>
>>>> <property name="name">mydata</property>
>>>> <property name="dataType">integer</property>
>>>> </structure>
>>>> </list-property>
>>>> <list-property name="columnHints">
>>>> <structure>
>>>> <property name="columnName">mydata</property>
>>>> </structure>
>>>> </list-property>
>>>> <structure name="cachedMetaData">
>>>> <list-property name="resultSet">
>>>> <structure>
>>>> <property name="position">1</property>
>>>> <property name="name">mydata</property>
>>>> <property name="dataType">integer</property>
>>>> </structure>
>>>> </list-property>
>>>> </structure>
>>>> <property name="dataSource">Data Source</property>
>>>> <method name="open"><![CDATA[i = 0;]]></method>
>>>> <method name="fetch"><![CDATA[if( i >= params["myrows"] ){
>>>> return false;
>>>> }else{
>>>> row.mydata = i;
>>>> i++
>>>> return true;
>>>> }]]></method>
>>>> </script-data-set>
>>>> </data-sets>
>>>> <styles>
>>>> <style name="crosstab" id="4">
>>>> <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="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>
>>>> </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>
>>>> <body>
>>>> <table id="9">
>>>> <property name="width">100%</property>
>>>> <property name="dataSet">Data Set</property>
>>>> <list-property name="visibility">
>>>> <structure>
>>>> <property name="format">all</property>
>>>> <expression name="valueExpr">if(row["RowCount"] ==
>>>> 0){
>>>> true;
>>>> }else{
>>>> false;
>>>> }</expression>
>>>> </structure>
>>>> </list-property>
>>>> <list-property name="boundDataColumns">
>>>> <structure>
>>>> <property name="name">mydata</property>
>>>> <expression
>>>> name="expression">dataSetRow["mydata"]</expression>
>>>> <property name="dataType">integer</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="name">RowCount</property>
>>>> <expression
>>>> name="expression">row.__rownum</expression>
>>>> <property name="dataType">decimal</property>
>>>> <property name="aggregateFunction">count</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="name">Column Binding</property>
>>>> <expression
>>>> name="expression">row["RowCount"]</expression>
>>>> <property name="dataType">integer</property>
>>>> </structure>
>>>> </list-property>
>>>> <column id="32"/>
>>>> <column id="18"/>
>>>> <header>
>>>> <row id="10">
>>>> <cell id="29"/>
>>>> <cell id="11">
>>>> <label id="12">
>>>> <text-property
>>>> name="text">mydata</text-property>
>>>> </label>
>>>> </cell>
>>>> </row>
>>>> </header>
>>>> <detail>
>>>> <row id="13">
>>>> <cell id="30">
>>>> <data id="33">
>>>> <property name="resultSetColumn">Column
>>>> Binding</property>
>>>> </data>
>>>> </cell>
>>>> <cell id="14">
>>>> <data id="15">
>>>> <property
>>>> name="resultSetColumn">mydata</property>
>>>> </data>
>>>> </cell>
>>>> </row>
>>>> </detail>
>>>> <footer>
>>>> <row id="16">
>>>> <cell id="31"/>
>>>> <cell id="17"/>
>>>> </row>
>>>> </footer>
>>>> </table>
>>>> <table id="34">
>>>> <property name="width">100%</property>
>>>> <property name="dataSet">Data Set</property>
>>>> <list-property name="visibility">
>>>> <structure>
>>>> <property name="format">all</property>
>>>> <expression name="valueExpr">if(row["RowCount"] ==
>>>> 0 ){
>>>> false;
>>>> }else{
>>>> true;
>>>> }</expression>
>>>> </structure>
>>>> </list-property>
>>>> <list-property name="boundDataColumns">
>>>> <structure>
>>>> <property name="name">mydata</property>
>>>> <expression
>>>> name="expression">dataSetRow["mydata"]</expression>
>>>> <property name="dataType">integer</property>
>>>> </structure>
>>>> <structure>
>>>> <property name="name">RowCount</property>
>>>> <expression
>>>> name="expression">row.__rownum</expression>
>>>> <property name="dataType">decimal</property>
>>>> <property name="aggregateFunction">count</property>
>>>> </structure>
>>>> </list-property>
>>>> <column id="43"/>
>>>> <header>
>>>> <row id="35">
>>>> <cell id="36">
>>>> <label id="37">
>>>> <text-property name="text">This Data Set
>>>> Contains No Data</text-property>
>>>> </label>
>>>> </cell>
>>>> </row>
>>>> </header>
>>>> <footer>
>>>> <row id="41">
>>>> <cell id="42"/>
>>>> </row>
>>>> </footer>
>>>> </table>
>>>> </body>
>>>> </report>
>>>>
>>>>
>>>> venc wrote:
>>>>> Hi,
>>>>> I want to detect "No Data" condition in scripted data source and
>>>>> display appropriate message "No Data exists for your parameter
>>>>> selection" instead of chart or table in report. How do i do this?
>>>>>
>>>>> I tried to use count in open/fetch method and check if its 0, but after
>>>>> this is executed there did not seem any way to prevent chart/table
>>>>> being rendered. If i supress the chart / table then open/fetch method
>>>>> is not executed.
>>>>>
>>>>> Thanks
>
|
|
|
Powered by
FUDForum. Page generated in 0.33717 seconds