Data Filter Overview
- 4 min to read
Filter records at data source level using your data connection query if you are binding to a large data source and want to speed up the retrieval process.
Use the report's settings demonstrated in this section if you want to load the entire dataset and filter it on the client.
Options described in this section allow you to emulate the Top N feature in a sorted report or increase the Print Preview performance by rendering only a subset of a report’s data.
Use this technique to hide certain report elements from the Detail band when the corresponding data records meet the specified criteria.
Filter a SQL Data Source
You can also apply filtering in an existing data source by right-clicking it in the Report Explorer or Field List and selecting Manage Queries. In the Manage Queries window, click the required query's ellipsis button.
In the invoked Query Editor, click the Run Query Builder button and use the Query Builder to specify the filter criteria as shown in the following image:
See Filter Data at the Data Source Level for detailed instructions on using query parameters.
Filter Data Using Report's Settings
Use the report's XtraReportBase.FilterString property to filter records at the report level. Locate this property using the report's smart tag and click the corresponding ellipsis button to invoke the Filter Editor.
You can filter detail report data individually in a master-detail report.
Limit the Number of Records to Display
You can filter records displayed in Print Preview using the ReportPrintOptions class.
Limiting the Number of Records
The ReportPrintOptions.DetailCountAtDesignTime property enables you to limit the number of records a report shows at design time in Visual Studio. Click the report's smart tag to access this setting as shown in the image below.
Printing on Empty Data Source
Disable the ReportPrintOptions.PrintOnEmptyDataSource option to avoid generating a report when its data source is empty. You can use this setting in master-detail reports to hide the detail report if its data source contains no records.
The ReportPrintOptions.DetailCountOnEmptyDataSource property allows you to specify how many times to print the Detail band when a report does not have a data source. You can use this property to create static reports that are not connected to a data source and display the same static content several times.
Conditionally Change Element Visibility
You can show or hide a specific report control in Print Preview based on a logical condition. For instance, the following example illustrates a document that displays the State field only if the Country value is "USA".
Select the target label on the report's surface, switch to the Property Grid's Expressions tab and click the XRControl.Visible property's ellipsis button.
In the invoked Expression Editor, specify the expression that defines when a control should be visible.