When Value of Drop-down Checkbox is None, Show All Data

  • Last update:  2021-12-24
  • I. Overview

    1. Problem description

    When using parameters for filtering, filtering will be carried out according to the selected value after selecting a parameter value. However, how to achieve the effect as shown in the following figure, that is, all values in the data table can be queried when no parameter value is selected in the drop-down checkbox. The effect is shown below:

    1.gif



    2. Solution

    You can select template parameters or dataset parameters from the drop-down checkbox. You can uncheck "Display Nothing Before Query" to realize displaying all data without click Query when parameter is none.

    II. Example 1: Using template parameter

    1. Create a dataset

    Add a dataset ds1, SQL statement: SELECT * FROM Sales_Volume.


    2. Design the report

    Add the table header on the first row and drag the fields of dataset ds1 into the cell in turn, as shown below:

    2.png


    3. Add the widgets

    1) Add a label widget with the value set to Region:, as shown below:

    3.png

    2) Add a "Drop-down Checkbox" widget named Region, select the Database Table for the Data Dictionary, the database is FRDemo, the database table is Sales_Volume, select Region for both the Actual Value and Displaye Value, and the Return Value Type is Array, as shown in the following figure:

    4.png


    3) Add Query widget, as shown below:5.png

    4) Click the blank of the parameter pane, and in the Attributes on the right, uncheck "Display Nothing Before Query", as shown below:6.png


    4. Set the filter

    Double-click A2, select the Filter, Available Columns as Region, then select Formula and enter: if(len($Region)==0,nofilter,$Region), as shown in the figure below:

    7.png


    Note: nofilter said not filter, the formula "if(len($Region)==0, nofilter, $Region) " means that if the parameter "Region" is empty, said don't filter the data, if not empty, the data will filter by "Region"..

    III. Example 2: Using dataset parameter

    1. Create a dataset

    Add a dataset ds1, SQL statement is: SELECT * FROM Sales_Volume where 1=1 ${if(len(Region) == 0, ""," and Region in ('" + Region + "')")}

    ${if(len(Region) == 0, ""," and Region in ('" + Region + "')")} indicates that if the paramter "Region" is empty, no filtering is performed. If the "Region" is not empty, the data will filter by "Region". As shown below:

    8.png

    Note:

    Where 1=1 indicates that the condition is always true, preventing error when there is no parameter condition.

    len(Region)==0 indicates that the parameter "Region" is empty.

    "Region" between"and Region in ('" + Region + "')")} means get the value of parameter, and '+' is a string concatenation symbol.



    2. Design the report

    The report design is shown in Section II.2 of this article.


    3. Add the widgets

    Edit the parameters pane, select Add All, select the Data Dictionary of Drop-down Checkbox widget to select the database table, the database is FRDemo, the database table is Sales_Volume, select Region for both the Actual Value and Display Value, and set the Return Value Type is String. The delimiter is ',', as shown below:

    9.png


    Click the blank of the parameter pane, and in the Attributes on the right, uncheck "Display Nothing Before Query", as shown in the figure below:

    10.png


    IV. Preview effect

    1. PC

    Click "Pagination Preview". Without select parameter value, click "Query" directly. The effect is shown in Section I.1 of this article.


    2. Mobile

    Preview effect of App and HTML5, as shown below:

    11.gif


    V. Download templates

    1) Example 1

    Please refer to the completed template: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Parameter\Checkbox_Selects_All(template).cpt

    Click to download the template: Checkbox_Selects_All(template).cpt

    2) Example 2

    Please refer to the completed template: %FR_HOME%\webroot\WEB-INF\reportlets\doc-EN\Parameter\Checkbox_Selects_All(dataset).cpt

    Click to download the template: Checkbox_Selects_All(dataset).cpt

    Attachment List


    Theme: Parameter
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy