How to give expression for the details band based

2019-09-04 02:57发布

I am using iReports 4.7.1

I have 2 sub reports in my main report and they are in saperate bands. I need to hide the band if sub report returns no rows. I am able to get subreport value in my main report. But if i use that variable as a expression in the same band the value of that variable is becoming null, If i use that same variable in other details band, it is not becoming null.

I have two question to ask,

  1. Why the value is becoming null if i use in same band?
  2. Is their any other way to hide subreport returns no rows?

I followed this steps to create variable and return value from subreport to main report.

And also i tried this new Boolean($V{SUB_REPORT_ROW_CNT}.intValue()!=0) or $V{SUB_REPORT_ROW_CNT} != null expression in print when expression for the band.

1条回答
看我几分像从前
2楼-- · 2019-09-04 03:17

Why the value is becoming null if i use in same band?

I need to see jrxml but probably you do not have correct EvaluationTime on the textField, try to set Band or Report example evaluationTime="Report" on the textField.

Is their any other way to hide subreport returns no rows?

The normal way to remove an empty subreport is by setting isRemoveLineWhenBlank="true" on the reportElement of the subreport.

Make sure your subreport return no page (empty) when no data by setting the whenNoDataType="NoPages" (or removing this attribute since this default) on the jasperReport tag

This will remove the subreport, note however if you like text under it to move you need to set positionType="Float", otherwise they will remain where they are since default is positionType="FixRelativeToTop"

查看更多
登录 后发表回答