Hiding grids/tables in BIRT whith no results from datasource

旧时模样 提交于 2019-12-23 01:16:15

问题


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.


回答1:


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.


来源:https://stackoverflow.com/questions/11741856/hiding-grids-tables-in-birt-whith-no-results-from-datasource

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!