Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to hide Table row based on a conditional expression


    stasp
    • Version: v6.4, v6.4.3, v6.4.2, v6.4.0, v6.3, v6.3.1, v6.3.0, v6.2, v6.2.1, v6.2.0, v6.1 Product: Jaspersoft® Studio

    How is it different from hiding non-table rows

    The basic principle of hiding a row in a Table component is the same as hiding a row, say, in a Detail band. However, since the Text fields in a Table are nested in cells, there are a couple of additional requirements that need to be met to hide a row successfully. The details are described below.

    Configuration steps

    In the example below we will hide a Table Group row header when the Country field is NULL. Since the Table data is grouped by Country, we do not want the report to display the header when Country value is set to NULL.

    1. Set a Print When Expression on ALL the Text fields in the Table row. If any of the Text fieds do not have the conditional expression the row will not be hidded even when the condition is met for the other fields in the row:

      hiding_table_row.png.d3c580b501528af8ff264d86f7c2d87d.png

    2. Outside the Table component this would in most cases be enough. For Tables, we also have to make sure the following conditions are also met:

      • The cell which needs to be hidden should be completely filled by the nested Text fields, both by width and height. This means that the height of all the Text fields should be exactly the same as the cell height. It also means that if any part of the cell does not have a nested Text field, you have to add an empty field there and set the conditional expression for it too.
      • The second requirement is that the cell has no borders. So if, for example, you are applying a style for the Table cell which sets the borders to anything other than 0 pixels, you'll have to remove the style from the cell. Instead, the style can be applied on the Text field level.

    This should be it. See an example report attached. It should run against any valid JDBC data source.

    Other notes

    If you are receiving an error like this:

    Field not found: myFieldName --- net.sf.jasperreports.engine.design.JRDesignExpression@c90ba2f

    it most likely means that you have specified the Print When Expression for a Table cell and not for a Text Field nested inside the cell. The problem here is that report fields and parameters are not visible on the cell level. The simple solution is, again, to add an empty Text field inside the cell, and set the conditional expression there.

    hiding_table_row.png.a0ad963fc149fbc002fb94d8ede6be9d.png

    support_tablehidedetail.jrxml


    User Feedback

    Recommended Comments

    Hi again, Thanks for this. 

    For me, although I had removed the borders from the column cells, the defaults style was still selected and the blank row was still showing. 

    However, when I removed the cell style completely (select all the table detail row's columns, click cell, and update cell properties: parent style to blank) it worked.

     

     

    Link to comment
    Share on other sites

    Hi, thanks for this. 

    This doesnt work in the case where you group column in the group header and create a cell for the grouped columns. 

    In my case, the row of my group header is (Column[5] - Column6 - Column7) with a cell for each.  There is no cells for Column 1, ..., Column 5 because the cell is created on Column[5]). 

    I applied the technique proposed on this page but the blank row is still showing. 

    However, if  i ungroup the columns and apply your solution then it work great. 

    Is there any solution to make it work with group columns ? 

    Best regard

     

    Link to comment
    Share on other sites

    Thank you for the advice.

    Personally, to get this working, I also had to check the "Remove Line When Blank" checkbox found in Table -> Text Field -> Appearance

    Hope this may help.

    Link to comment
    Share on other sites

    Using OOTB Jasper Reports Template from Windchill 12.0.2.1 , "Change Notice Summary Report.jrxml" in the jasper studio community edition.

    ECN attribute "ECO Type" and its value is "Pre-Incorporated." , other user defined attributes exist in the ECN as well, all attributes are shown OOTB.  

    To filter those out, in the OOTB Template use this in the NAME text field:

    $F{NAME}.equals("ECO type") ? $F{NAME} : ""

    Use this to filter the VALUE text field:

    $F{NAME}.equals("ECO type") ? $F{VALUE} : ""

    To hide the rows that do not match the criteria because their results will be null (empty), add this to the Detail Properties within the specific Table.

    Print When Expression: $F{NAME}.equals("ECO type") 

    I hope this helps fellow Windchill users.

    Link to comment
    Share on other sites



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...