Hiding grids/tables in BIRT whith no results from datasource

11,405

You can do this using the visibilty tab on the property editor.

  1. On you data table (or the grid containing it if you want to hide the whole grid) go to binding tab.
  2. Add an aggregation with function "COUNT" and select one of the data set fields for the expression.
  3. Go to the properties->Visibilty tab and tick "Hide Element" and in the expression put row["Aggregation"] == 0 replacing the aggregation name if necessary.
  4. Create a 1x1 grid containing a "No data present" label.
  5. Associate the grid with the data set and add the same aggregation as above.
  6. On the Visibility tab click "Hide Element" again, but using row["Aggregation"] != 0 this time.
Share:
11,405

Related videos on Youtube

user1565916
Author by

user1565916

Updated on June 04, 2022

Comments

  • user1565916
    user1565916 almost 2 years

    I am having trouble altering a report in birt to meet my teams specifications.

    The problem is this: I am generating a report from a jdbc datasource. I am selecting items from the DB such that there is either one row or none. If there is a row returned, I show data reflecting the results. If there is no row returned though, I should hide the entire grid that the data should have been shown in and show a simple message, "no data can be found."

    I have tried different actions like adding a count to the query and the computed count from the plugin, but if no results are given then there is no count to go off of. I have also tried creating a boolean parameter showHideData that is defaulted to true and if one of the key fields is null, then showHideData is set to false. This looked as such (I placed it in the datasets afterClose script option):

        if(row["FIRM"] != null){
            params["showHideData"] = true;
        }else {
            params["showHideData"] = false;
        }
    

    This unfortunately gives me a javascript error saying that it cannot access the null value. I am not sure how to do this because I am not well versed in Javascript, but I would appreciate any help you could give.

  • user1565916
    user1565916 almost 12 years
    Thank you so much! This is just what I was looking for. I tried a ton of variations, but I feel silly having not tried this one. Thank you so much for the help!
  • user1565916
    user1565916 almost 12 years
    I got this method to work, but can you think of a way to possibly do this in javascript only, so that it becomes more portable? My current thought is to check if the length of one of the char fields is 0 (null) or not, but I think I will hit the same snag as before.