[]
        
(Showing Draft Content)

Tutorial 2: Create a Parameterized Report

Parameters in reports are used to filter the data based on certain criteria. You can either prompt users to enter parameters so that they have control on the final output, or supply the parameters behind the scenes.

This tutorial guides you through the steps to add parameters and use them as prompts before displaying the final output.

After you complete this tutorial, you will have a report that looks similar to the following.

The parameters selected on preview are - Parameter1 = RJ and Parameter2 = HANAR as shown:

Bind Data to Report

  1. Create a new report. By default, you have a blank RDL Report.

  2. Connect to a data source.

    1. Go to the Data tab and click Add.

    2. In the DataSource dialog, provide the following URL as Endpoint for the 'Remote JSON' provider:

    https://demodata.grapecity.com/northwind/odata/v1/Orders
    
  3. Add a dataset.

    1. Click Add Data Set against the added data source.

    2. In the DataSet dialog, enter the Json Path: $.value[*].
      See Databinding for information on connecting to data sources and adding datasets.

Create Data-bound Table

  1. Expand the dataset fields and enable Select Fields...

  2. Select the fields required in the table and drag-drop onto the design area.

    A table with its columns bound to the fields is created. The Header row above the details row is automatically filled with labels.

Alternatively, you can first drag-drop the Table data region onto the design area of the report and then populate the data by dragging and dropping the fields onto the details row.

Add Parameter to the Report

Let us add two parameters that would act as filters to retrieve data - one parameter will be used as a filter for the ship region, and the other will be used as a filter for customer id.

To add a report parameter that filters the data based on the ship region,

  1. From the top right corner of the Report Designer, click the Data icon .

  2. Click Add next to Parameters. A parameter, Parameter1 is added.

  3. Click Parameter1 to edit parameter properties.

  4. Set the Data Type property to String.

  5. Go to From query tab and set the following properties.

    | Property | Value | | -------- | ----- | | Data Set Name | Dataset | | Value Field | ShipRegion | | Label Field | ShipRegion |

    The following image shows how these properties are set:

    To add a parameter that filters the data based on the customer id,

  6. From the top right corner of the Report Designer, click the Data icon .

  7. Click Add next to Parameters, a parameter Parameter2 is added.

  8. Click Parameter2 to edit its properties.

  9. Set the Data Type property to String.

  10. Go to From query tab and set the following properties.

    | Property | Value | | -------- | ----- | | Data Set Name | Dataset | | Value Field | CustomerId | | Label Field | CustomerId |

The following image shows how these properties are set:

The Parameters property now shows two parameters.

Manage Data in the Report

To control the amount of data rendered in the report, we will pass the parameters as filters to the Table data region.

To add a filter that renders data according to the ship region parameter (Parameter1),

  1. Select the table and go to the Properties pane.

  2. In the Filters property, go to Show Items, and select Add Item.

  3. Click to display the filter properties.

  4. Click the radio button next to Filter Expression, select ShipRegion.

  5. From the drop-down next to Operator, select 'Equal'.

  6. Click the radio button next to Value and enter the expression =Parameters!Parameter1.Value.

To add another filter that limits the data according to customer id parameter (Parameter2),

  1. In the Filters property, click Show Items and then select Add Item.

  2. Click to display the filter properties.

  3. Click the radio button next to Filter Expression to display the fields and select CustomerId.

  4. From the drop-down next to Operator, select 'Equal'.

  5. Click the radio button next to Value and enter the expression =Parameters!Parameter2.Value.
    The Filters property now shows the two filters as follows.

Add Page Header

  1. Go to the Report tab on top of the designer and select the Add Header option.

  2. Drag and drop a TextBox control in the header area.

  3. Click inside the text box and enter the text 'Customer Orders Report'.

Customize the Appearance of the Report

Note: You may need to resize and reposition the controls on the report to accommodate data, and for a cleaner look.

  1. Set the text alignments using TEXT - Text Align (Left, Right, Center, etc.) and TEXT - Vertical Text Align (Top, Middle, or Bottom) properties.

  2. Set a background color for Page Header and Header row of the table (#f1f1f1).

  3. Set a font using the Font Family property (Song).

  4. Set the color for the text in the page header using TEXT - Color property (#3da7a8).

  5. Set the TEXT - Font Size for the text in the page header (16pt) and the text in the table (8pt).

  6. Set the border properties for the textboxes in the table - Border - Width (0.25pt), Border - Style (Solid), and Border - Color (Gainsboro).

Preview and Save Report

  1. Click Preview to view your report in the final output. You will be prompted to enter two parameters - select the ship region and the customer id for which you want to view the report, and again click Preview.

    Note: The values in the Parameter list appear sorted only if the data values are sorted in the dataset.

  2. Exit the preview mode by clicking Back on the left side of the designer.

  3. Click Save to open the Save dialog box. Enter the report name and click Save Report.