Entirely modified, including 2 cases

This commit is contained in:
Todor Arabadzhiev 2018-03-08 17:00:33 +02:00 коммит произвёл GitHub
Родитель 1aa52dd9f0
Коммит a7929fed30
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 16 добавлений и 5 удалений

Просмотреть файл

@ -24,13 +24,24 @@ res_type: kb
## Description
Sometimes you would like to hide the Subreport(s) (i.e. Report Header/Footer and the Detail Section) if there is no data in it.
The Detail Section is rendered for each data record, so if there is no data, there will be no Detail Section in the SubReport. However, the Report Header/Footer would still be rendered, and the Subreport item inside the main report would still occupy the preserved (design-time) space.
Sometimes you would like to hide the Subreport(s) (i.e. Report Header/Footer and the Detail Section) if there is no data to display inside.
By default the Subreport item inside the main report would occupy the preserved (design-time) space even if its content is empty.
The Detail Section is rendered for each data record, so if there is no data, there will be no Detail Section in the (Sub)report. However, the (Sub)report Header/Footer would still be rendered.
## Solution
1. To hide the SubReport Header/Footer you could use [Bindings ](https://docs.telerik.com/reporting/expressions-bindings) to set its Visible property to True only when there is data (for example_'=Count(Fields.SomeFieldValue) \> 0'_).
1. Forcing the Subreport item not to occupy space in the main report when empty:
To mimic hiding of the Subreport item inside the main report, you could set its height to '0' (zero inches).
This way it will not occupy space when there is nothing to render. However, when there is data in the Subreport, it will grow downwards automatically to occupy the needed space.
2. Forcing the report referenced by the Subreport item to render blank/empty when there is no data:
When the Subreport DataSource is not directly dependent on the main report DataSource it is enough to hide the Subreport Header/Footer when there is no data. You could use [Bindings ](https://docs.telerik.com/reporting/expressions-bindings) to set Header/Footer _Visible_ property, for example with the expression _'=Count(Fields.SomeFieldValue) \> 0'_.
When the Subreport DataSource is directly dependent on the main report DataSource, i.e. it is set (using Bindings) with the expression '= ReportItem.DataObject', you can use another Binding (also directly on the Report referenced by the Subreport item) to set its _Visible_ property to an expression evaluated to _True_ only when the 'ReportItem.DataObject.SubreportData' is not Null/empty - for example when 'SomeFieldValue' is a single string passed from main report to the Subreport, the expression could lool like '= ReportItem.DataObject.SomeFieldValue <> ""'.
2. To mimic hiding of the Subreport item inside the main report, you could set its height to 0in (zero inches).
This way it will not occupy space when there is nothing to render. However, when there is data in the SubReport, it will grow automatically to occupy the needed space.