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

ssangadi276 picture ssangadi276 · Aug 21, 2014 · Viewed 9.9k times · Source

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.

Answer

Miki picture Miki · Aug 21, 2014

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