I. Overview
1. Problem description
It is hoped that the default value of the widget is not fixed, but is dynamically obtained based on database data. For example, get the maximum value in a column.
2. Solutions
Use report-like functions to get the database data, and do some custom processing, as the default value of the widget.
II. Example
1. Data preparation
Create a new ds1 data set, fetch the data from FRDemo, enter the sql statement: SELECT * FROM SaleRental
2. Report design
Add a drop-down box widget in theTemplate Parameter, the data dictionary is bound to ds1, the actual value and the displayed value are both Sales Volume.
3. Default value setting
Select the drop-down box widget, select the Formula in "Widget Settings>Attributes>Advanced>Widget Value", and enter the following formula: max(value("ds1","Sales Volume"))
4. Effect preview
Click Preview, you can see that the drop-down box defaults to the maximum value of 2261.0.
III. Template download
Click to download the template: Widget_dynamic_default_value.cpt
IV. Precautions
In addition to the above scheme, you can also directly use SQL to retrieve the maximum value in the data set, and then set the default value of the widget to the field value of the data set.