If you apply a filter to the data in a report, then we recommend that you create an additional header row in the report to display the filter. You display this header row only if the user specifies a filter. If no filter is specified, then the filter header is not displayed.
To conditionally display the filter header, you must add a filter variable to the report dataset. Next, in the RDLC report layout, you must create a conditional expression on the visibility of the filter header that uses the filter variable that you added to the dataset.
An example of a report that has additional header rows to display filter information is report 113, Customer/Item Sales.
To hide non-filtered headers
-
In the development environment, on the Tools menu, choose Object Designer.
-
In Object Designer, choose Report, select the report that you want to modify, and then choose Design.
-
On the View menu, choose C/AL Globals.
-
In the C/AL Globals window, on the Variables tab, add a new variable for the filter. The DataType of the variable is Text.
-
On the View menu, choose C/AL Code.
-
In the C/AL Editor, in the OnPreReport trigger, add code to get the filters. For example, if you have a filter on the Customer table and the filter variable that you created is named CustFilter, then add the following code.
Copy Code CustFilter := Customer.GETFILTERS;
-
In Report Dataset Designer, under the DataItem for the table to which a filter can be applied, add a new line.
-
In the Data Type field of the new line, choose Column.
-
In the Data Source field of the new line, enter the name of the filter variable.
-
On the File menu, choose Save. In the Save dialog box, verify that Compiled is selected, and then choose OK.
-
On the View menu, choose Layout.
-
In Microsoft Visual Studio, on the View menu, choose Toolbox.
From the Toolbox, under Report Items, drag a Text Box to the report layout.
-
Select the filter header text box that you created in step 12, and then on the View menu, choose Properties Window.
-
In the Properties window, expand the Visibility field. In the Hidden field, select <Expression…> from the drop-down list.
-
In the Expression window, create a conditional statement. For example, the following are the conditional statements for the two filter text boxes on report 113.
Copy Code =IIF(First(Fields!CustFilter.Value) = "",TRUE,FALSE)
Copy Code IIF(First(Fields!ItemLedgEntryFilter.Value) = "",TRUE,FALSE)
-
Save and compile the report. For more information, see How to: Integrate Report Dataset Designer and Visual Studio Report Designer.