I. Overview
When performing secondary development on the parameter pane, sometimes it is necessary to obtain the objects of the parameter pane. How can we do that?
II. Example
2.1 Obtain when in the parameter pane
Use JavaScript directly in the parameter pane and get the widget, you can use it directly:
this.options.form.getWidgetByName("widgetname")
Note: If you are getting the current widget, you can directly use this instead.
2.2 Obtain through the integrated web page
To get the object of parameter pane in the report through integrated web page, you need to use:
document.getElementById('reportFrame').contentWindow.contentPane.parameterEl.getWidgetByName('widgetname')
Note: reportFrame is the FineReport iframe embedded in the Web page.
2.3 Obtain through the report body
To get the widget of the parameter pane through the main body of the report, namely in the cell, you need to use:
contentPane.parameterEl.getWidgetByName("widgetname")
III. List of widget operations
After obtaining the widget, you can perform further operations on it. For example, you can get its widget value, assign a value, set whether it is visible, and so on. The list of available operations is as follows:
Method name | Method | Description |
---|---|---|
Take actual value | Widget.getValue() | Get the actual value of the widget |
Take the displayed value | Widget.getText() | Get the display value of the widget |
Assign actual value | Widget.setValue() | Assign values to parameter widget, it is not recommended to assign actual values to the data entry widget |
Assign display value | Widget.setText() | Assign display value to parameter widget |
Reset | Widget.reset() | Clear data |
visible | Widget.visible() | Set the widget to be visible |
Invisible | Widget.invisible() | Set the widget to be not visible |
Is it visible | Widget.isVisible() | Returns whether the widget is visible, returns true to be visible, false to be invisible |
Set visible | Widget.setVisible(boolean) | Set whether the widget is visible, the parameter is true to be visible, false to be invisible |
Set enabled | Widget.setEnable(boolean) | Set whether the widget is enabled, the parameter is true to be enabled, false is off |
Is it enabled | Widget.isEnabled() | Return whether the widget is enabled, return true to be enabled, false to be off |
Call widget event | Widget.fireEvent("Event Name") | Set the widget to trigger an event with the specified name |
Can it be empty | Widget.options.allowBlank=false | Set whether the widget can be empty, true can be empty, false can not be empty |
Note:
Widget is the obtained widget object.
If you use setValue() to assign a value to the drop-down tree, you need to add a false parameter, namely setValue(value,false); value is the value that needs to be assigned to the drop-down tree.