Widget dynamic default value

  • Last update:June 06, 2025
  • Overview

    Problem

    You do not want a fixed default value for a widget. Instead, you want a default value obtained dynamically according to database data. For example, you want to obtain the maximum value in a column.

    Solution

    You can use report functions to obtain the database data and customize a default value for a widget.

    Example

    Data Preparation

    1. Create a general report.

    2. Create a database query ds1 with the SQL query statement SELECT * FROM SaleRental.

    1.png

    Report Design

    1. Add a drop-down box widget to the parameter panel.

    2. Select the drop-down box widget, bind the dataset ds1, and set Actual Value and Display Value to Sales Volume separately in the Data Dictionary setting box, as shown in the following figure.

    2.png

    Default Value Setting

    Select the drop-down box widget and enter max(value("ds1",2)) in the formula input box under Widget Setting > Attribute > Advanced > Widget Value, as shown in the following figure.

    3.png

    Effect Display

    Click Pagination Preview. The maximum value 2261.0 is displayed in the drop-down box by default.

    7.png

    The following figure shows the preview effect on the DataAnalyst app and the HTML5 terminal.

    8.jpg

    Template Download

    For details, you can download the template Dynamic Default Value of a Widget.cpt.

    Notes

    In addition to the above-mentioned solution, you can also obtain the maximum value of the dataset by a SQL statement and set the default value of the widget to be the maximum field value of the dataset.

    6.png


    Attachment List


    Theme: Parameter
    • 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