I. Overview
When using a widget, you may need to assign an initial value to the widget, that is, perform default value processing. Widgets can be divided into reporting widgets and parameter widgets according to different usage methods. The following describes their default value assignment methods.
II. Assignment method
There are many ways to assign the default value of the widget, as shown in the following table:
Assignment method | Introduction | Examples |
---|---|---|
The value of the system parameter | The default value of the system parameter given by FineReport | System parameter |
URL parameter transfer | When previewing the template on the web side, attach the parameter default value after the URL | http://localhost:8075/webroot/decision/view/report?viewlet=test.cpt&p1=a |
The default value of the parameters set when mounting the template in the decision-making platform | ![]() | |
Parameter panel widgetvalue | The initial value assigned to the widget in the property panel of the widget | ![]() |
Template parameter default value | Initial value assigned when global and template parameter is defined | ![]() |
Global parameter default value | Initial value assigned when global parameter is defined | ![]() |
Dataset parameter default value | Initial values of parameters defined in the dataset | ![]() |
III. Priority Principle
When there are different types of parameters in the template and multiple parameters have the same name, the default value of the parameter with the highest priority is displayed.
The priority of the parameters is as follows: system parameter value>URL parameter transfer>parameter panel widget value>template parameter default value>global parameter default value>dataset parameter default value
For example: when the URL passing parameter p1 has the value a, the default value of the template parameterp1 is b. When previewing the template, the default value of the parameter is awith higher priority.
IV. Example 1: Data entry widget defaults
1.Application scenario
We often hope that the widget has an initial value before filling in the reporting interface, and this initial value is actually the default value of the widget. As shown in the following figure:
2. Realization Ideas
General Report: Enter the default value directly in the cell where the widget is located.
Dashboard: Design widget Defaults in the Parameter Pane.
3. Steps
1) General Report
Enter a value in the cell where the widget is located, as shown in the following figure:
2) Dashboard
In the dashboard, just fill in the default value in the widget value. As shown in the following figure:
V. Example 2: Default value of parameter widget
1. Application scenarios
We often hope that the report widget can be displayed according to the default value on the parameter pane before clicking the query button. As shown below:
2. Implementation ideas
There are three methods for setting the initial value of the parameter widget:
Template parameter setting default value
Parameter panel widget value setting default value
URL parameter transfer
3. steps
1) Default value of template parameter setting
Set the parameter default value in the define parameter interface, and the parameter widget will automatically obtain the parameter default value as the initial value of the widget. For example, when defining the template parameter p1, set the default value to East China. When defining the parameter interface, the widget value of the p1 parameter widget defaults to East China, and the dataset parameters are the same. As shown below:
Note: You must set the parameter default value first and define the parameter widget before the initial widget value is the parameter default value. If the widget has been defined, then modify the parameter default value, this time the widget value will not change,that is, on the parameter interface,the initial value of will not change. Therefore, if you want to modify the default value of the parameter interface, you can directly modify the widget value of the parameter widget.
2) Setting default value of parameter panel widget value
The default value is not set when the parameter is defined, and the default value is set in the widget value property of the parameter widget. For example, define the template parameter p1 without setting the default value. After defining the parameter interface, select the parameter widget in the parameter interface and set it in the widget's "Attributs>Advanced>Widget Value". The dataset parameters are the same. As shown below:
3) URL parameter transfer
Follow the URL with the initial value of the parameter, and the parameter interface will display the value in the url. For example, to access the report http://localhost:8075/webroot/decision/view/report?viewlet=GettingStartedEN.cpt&Region=North China, the widget value on the parameter interface is the value in the URL, as shown in the following figure: