Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display "No Data" message when table is empty in BIRT Report

Tags:

birt

I want to hide a table and to report that "No Data" message is present if the query returns no data. In computed columns i have added the columns which counts the number of rows present(i.e.TableCheck). and i have created label just below the table with the message "No Data". In script onCreate i have added the below code.

if( countOfRows == 0 ){
this.getStyle().fontStyle = "italic";
this.getStyle().fontSize = "large";
}else{
this.text = "";
}

countOfRows = 0 is initialize in script.

In table visibilty propery, checked the Hide Element and added the below code in expression.

if (row["TableCheck"] == null){
    true
}
else{
    false
}

Problem: When dataSet is empty "No Data" Message is displaying.But when data set is not empty, then error message is not hiding.

Please let me know how to fix this.

Thanks in Advance.

like image 228
ssangadi276 Avatar asked Aug 21 '14 12:08

ssangadi276


People also ask

How do I hide grid in BIRT report?

Go to the properties->Visibilty tab and tick "Hide Element" and in the expression put row["Aggregation"] == 0 replacing the aggregation name if necessary. Create a 1x1 grid containing a "No data present" label. Associate the grid with the data set and add the same aggregation as above.

How do I hide a column in Birt?

You can click the column heading and use the Visibility property to define when to show or hide the column.


2 Answers

Do it this way: First add visual elements to display it when data set doesn't return any row.

Then define global variable in Initialize script of report root. For example

rowsReturned = 0;

On your table that you'll evaluate data set to see is there rows returned on Visibility tab set next:

enter image description here

On elements you want to display whene there is no returned data set this on Visibility tab

enter image description here

like image 182
Miki Avatar answered Sep 18 '22 14:09

Miki


If you want to hide the table when no data returned, you can write this in its Visibility property:

row.__rownum < 0

and in Visibility property of your "No Data" message you use the opposite check:

row.__rownum >= 0

Note that both components must be bound to the data set you want to check. In the case of the message component you can achieve this putting it in a header or footer row.

like image 20
kelgwiin Avatar answered Sep 20 '22 14:09

kelgwiin