Lesson 2 - Filter a Report on the Server using LightSwitch Query

This document explains how you can filter your report's data on the server-side by utilizing a LightSwitch query.

In this tutorial, we will use the report created in the preceding lesson: Lesson 1 - Create a Data-Aware Report.

To learn how to apply the server-side filtering to your report, do the following.

  1. Switch to the Solution Explorer (CTRL+ALT+L), expand the application's Data Sources and in the NorthwindData data source, right-click the Customers table. In the invoked menu, click Add Query.

    lightswitch-lesson-2-01

  2. In the invoked Application Designer, add new filtering criterion, and define a new parameter for its expression.

    For example, in this tutorial we will filter the report by sorting out records that belong to the country name that is specified using a string parameter.

    lightswitch-lesson-2-03

    If required, you can also apply sorting criteria to this query.

    After you have finished modifying the query, save the changes and rebuild the application.

  3. In the Solution Explorer, switch to the File View, and double-click XtraReport1 to show its designer.

    Click the report's smart tag, and modify the XtraReportBase.DataSource property value so that it is set to the created query.

    lightswitch-lesson-2-02

    Following this step, you can access the query's options to view its collection of parameters.

    lightswitch-lesson-2-04

Run the application and view the result: you can use the Parameters panel of the report's Print Preview to pass values to the query parameter, which then creates the report document.

lightswitch-lesson-2-05

See Also