Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"No data found." text in Jasper Report

I would like to do the report using iReport which can but does not have to display rows. How can I force Jasper Reports to display the text "No data found." when the query returns no data. I would like to have the same header as when there are rows.

I know I should change the report property "When No Data" to display something but I don't know how to implement the condition for no rows.

like image 343
saric Avatar asked Dec 10 '22 07:12

saric


1 Answers

I have found it out myself.

This could be done by following these steps:

  1. Add the "No Data" section from the sections list in the "Report Inspector". Right click it and choose "Add Band". After this, new section will be added to your report.
  2. Add any content to the new added section, e.g. "No Data found." message (if you would like the same header as in "normal" report, you have to copy it from the "Header" section to "No Data" section).

If you don't have the report property "When No Data" set to "No Data Section" set it so or follow these steps:

  1. Display report property by right clicking on the report and choosing "Properties" from the displayed menu.
  2. Find the section "More..." and in it you will see "When No Data" property, change it to "No Data Section".

After following the above, your report will show the "No Data" section when there will be no data, oterwise it will show the section as before.

like image 140
saric Avatar answered Dec 14 '22 23:12

saric