Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to hide the table header when there is no content in the table ?
How to hide the table header when there is no content in the table ? [message #666373] Wed, 20 April 2011 04:19 Go to next message
RWIL Mising name is currently offline RWIL Mising name
Messages: 28
Registered: February 2011
Junior Member
Hi,

I have a table with a header row, based on a dataset. Sometimes, the dataset is empty. Presently, the header row is always visible, even if the table content is empty.

I've tried to use the "visibility" property in the row of the table header. I've put a conditial hide "row[0] == 0", but it does not work, probably because row[0] means nothing in the table header.

Any idea ?
Re: How to hide the table header when there is no content in the table ? [message #666650 is a reply to message #666373] Thu, 21 April 2011 09:13 Go to previous messageGo to next message
RWIL Mising name is currently offline RWIL Mising name
Messages: 28
Registered: February 2011
Junior Member
I've found a solution for this problem, but it's more a workaround than a real solution.

In my table, I add a group at the first level, with the value "1" as Group On criterion. I move my header row from the table header to the group header and it's done. Now, if the content of the table is empty, my header row is hidden and if the table has at least one line, the header row is displayed.

It's working, but it's not very nice. I have to add "dummy" group which is useless just to make the header row conditionnal to the content.

If anybody knows a better solution, feel free to share it... Smile

[Updated on: Thu, 21 April 2011 09:14]

Report message to a moderator

Re: How to hide the table header when there is no content in the table ? [message #666685 is a reply to message #666650] Thu, 21 April 2011 11:16 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

You can always add an running count aggregate to the table bindings and
use that in a visibility expression for the table.

Look at the attached example. Select the table and then look at the
binding tab. You will see a column called MyRowCount which is an
aggregate that counts the number of rows. Then look at the visibility
expression for the table.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.22"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.6.1.v20100902 Build &lt;2.6.1.v20100915-1750></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="order" id="8">
<property name="valueType">static</property>
<property name="dataType">string</property>
<property name="distinct">true</property>
<simple-property-list name="defaultValue">
<value type="constant">10101</value>
</simple-property-list>
<property name="paramType">simple</property>
<property name="controlType">text-box</property>
<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="6">
<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="Data Set" id="7">
<list-property name="parameters">
<structure>
<property name="name">param_1</property>
<property name="paramName">order</property>
<property name="nativeName"></property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
<property name="position">1</property>
<property name="isOptional">true</property>
<property name="allowNull">true</property>
<property name="isInput">true</property>
<property name="isOutput">false</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>
</structure>
<structure>
<property name="position">2</property>
<property name="name">PRODUCTCODE</property>
<property name="nativeName">PRODUCTCODE</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">QUANTITYORDERED</property>
<property name="nativeName">QUANTITYORDERED</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">4</property>
<property name="name">PRICEEACH</property>
<property name="nativeName">PRICEEACH</property>
<property name="dataType">float</property>
</structure>
<structure>
<property name="position">5</property>
<property name="name">ORDERLINENUMBER</property>
<property name="nativeName">ORDERLINENUMBER</property>
<property name="dataType">integer</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select *
from orderdetails
where ordernumber = ?]]></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:DataSetParameters>
<design:parameterDefinitions>
<design:inOutMode>In</design:inOutMode>
<design:attributes>
<design:name></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:attributes>
<design:inputAttributes>
<design:elementAttributes>
<design:optional>true</design:optional>
</design:elementAttributes>
</design:inputAttributes>
</design:parameterDefinitions>
</design:DataSetParameters>
</model:DesignValues>]]></xml-property>
</oda-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">
<property name="topMargin">1in</property>
<property name="leftMargin">1.25in</property>
<property name="bottomMargin">1in</property>
<property name="rightMargin">1.25in</property>
<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"
type="javascript">(row["MyRowCount"] &lt; 1)</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">ORDERNUMBER</property>
<text-property
name="displayName">ORDERNUMBER</text-property>
<expression
name="expression">dataSetRow["ORDERNUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRODUCTCODE</property>
<text-property
name="displayName">PRODUCTCODE</text-property>
<expression
name="expression">dataSetRow["PRODUCTCODE"]</expression >
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">QUANTITYORDERED</property>
<text-property
name="displayName">QUANTITYORDERED</text-property>
<expression
name="expression">dataSetRow["QUANTITYORDERED"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">PRICEEACH</property>
<text-property
name="displayName">PRICEEACH</text-property>
<expression
name="expression">dataSetRow["PRICEEACH"]</expression>
<property name="dataType">float</property>
</structure>
<structure>
<property name="name">ORDERLINENUMBER</property>
<text-property
name="displayName">ORDERLINENUMBER</text-property>
<expression
name="expression">dataSetRow["ORDERLINENUMBER"]</expression >
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">MyRowCount</property>
<property name="dataType">integer</property>
<property
name="aggregateFunction">RUNNINGCOUNT</property>
<list-property name="arguments">
<structure>
<property name="name">Expression</property>
<expression name="value"
type="javascript">row["ORDERNUMBER"]</expression>
</structure>
</list-property>
</structure>
</list-property>
<column id="38"/>
<column id="39"/>
<column id="40"/>
<column id="41"/>
<column id="42"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property
name="text">ORDERNUMBER</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property
name="text">PRODUCTCODE</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property
name="text">QUANTITYORDERED</text-property>
</label>
</cell>
<cell id="17">
<label id="18">
<text-property
name="text">PRICEEACH</text-property>
</label>
</cell>
<cell id="19">
<label id="20">
<text-property
name="text">ORDERLINENUMBER</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="21">
<cell id="22">
<data id="23">
<property
name="resultSetColumn">ORDERNUMBER</property>
</data>
</cell>
<cell id="24">
<data id="25">
<property
name="resultSetColumn">PRODUCTCODE</property>
</data>
</cell>
<cell id="26">
<data id="27">
<property
name="resultSetColumn">QUANTITYORDERED</property>
</data>
</cell>
<cell id="28">
<data id="29">
<property
name="resultSetColumn">PRICEEACH</property>
</data>
</cell>
<cell id="30">
<data id="31">
<property
name="resultSetColumn">ORDERLINENUMBER</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="32">
<cell id="33"/>
<cell id="34"/>
<cell id="35"/>
<cell id="36"/>
<cell id="37"/>
</row>
</footer>
</table>
</body>
</report>

On 4/21/2011 9:13 AM, RWIL wrote:
> I've found a solution for this problem, but it's more a workaround than
> a real solution.
> In my table, I add a group at the first level, with the value "1" as
> Group On criterion. I move my header row from the table header to the
> group header and it's done. Now, if the content of the table is empty,
> my header row is hidden and if the table has at least one line, the
> header row is displayed.
>
> It's working, but it's not very nice. I have to add "dummy" group who
> are useless just to make the header row conditionnal to the content.
>
> If anybody knows a better solution, feel free to share it... :)
>


Jason Weathersby

BIRT Exchange
Re: How to hide the table header when there is no content in the table ? [message #740876 is a reply to message #666373] Tue, 18 October 2011 21:00 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing name
Messages: 1
Registered: October 2011
Junior Member
Sorry to dig up an old thread.

To hide a table I just use this in the visibility expression:

(Total.count() < 1)

And it works for me.

I was having some trouble hiding a group header row if the group was empty, and I used your example above to get the group count and hide the row.

In my situation, I had 2 group header rows and a group footer row. I wanted to keep 1 group header row to show that the group existed but was empty, but wanted to hide the 2nd group header row and group footer row.

The only thing different I did was in the bindings, rather than do the running count on the table, I did a running count on the group. Then put the '(row["MyRowCount"] < 1)' in the visibility expression on the two rows I wanted to hide.

Thanks.




Re: How to hide the table header when there is no content in the table ? [message #890134 is a reply to message #666373] Thu, 21 June 2012 04:57 Go to previous message
Bluish Joe is currently offline Bluish Joe
Messages: 13
Registered: October 2010
Junior Member
I found a simpler solution, even if I'm not 100% sure it's reliable.

Table Properties > Visibility > Hide Element, Expression =
row.__rownum == -1
.
Previous Topic:How to write an expression which uses items from multiple data sets?
Next Topic:Hide empty table
Goto Forum:
  


Current Time: Wed Apr 23 02:40:55 EDT 2014

Powered by FUDForum. Page generated in 0.09557 seconds