I. Description
Scenario description: After the report is reviewed and submitted, and after the data entry submitted successfully, we hope to change the attributes of some buttons in the toolbar, such as enabled/disabled, visible/invisible, to prevent other misoperations.
As shown below, after successful submission, the printing and output functions are disabled:
You will learn |
---|
|
II. Ideas
We can use JS to control on-off of buttons according to the serial number of buttons by using the event of “Data Entry Successful” in the Data Entry Settings page on “Template Web Attributes”.
III. Operating steps
Open the report %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\RowForm\Simple_Row-based_Form.cpt
Select Template > Template Web attribute > Data Entry Settings, and add a “Data Entry Successful” event, as shown below:
contentPane.toolbar.options.items[3].setEnable(false);
// The subscript starts from 0 from left to right, and the fourth button (Print) is disabled
contentPane.toolbar.options.items[4].setEnable(false);
// The subscript starts from 0 from left to right, and the fifth button (Output) is disabled
Note: When setting attributes, the button used to trigger events should not be set as disabled (that is, the “Submit” button cannot be set)
Code interpretation:
contentPane.toolbar.options.items: What is returned is an array collection of all buttons on the toolbar, which is referenced by subscripts (starting from 0).
Method name | Method | Description |
Enabled | Button. setEnable(true) | Settings button is enabled |
Disabled | Button. setEnable(false) | Settings button is disabled |
Visible | Button. setVisible(true) | Set the widget as visible |
Invisible | Button. setVisible(false) | Set the widget as invisible |
IV. Preview
4.1 Preview on PC terminal
Save the template and use the Data Entry Preview. The preview effect is as above.
Note: In our testing, the mobile terminal temporarily does not support this effect.
V. Completed template
Click Download Template:
JS control tool bar button attributes.cpt
https://help.fanruan.com/finereport/doc-view-1805.html