Overview
Version
FineReport Version |
---|
11.0 |
Upgrades
FineReport V11.0 provides a new JS API manual, which explains the usage of each interface in detail, helping you design the front-end report. Compared with the JS interface of V10.0, the interfaces of V11.0 have the following advantages:
The interfaces are unified. Except for some special cases, a function has the same effect in both dashboard and general report. Besides, the interfaces show you which functions are available on mobile devices.
The interfaces have clear structure, accurate scope and integrality. There is detailed explanation on the usage of each interface, which is user-friendly as well.
V11.0 makes frequently-used scenes as in V10.0 into interfaces rather than codes. The result of it is good compatibility and less impact on the codes when upgrading. The scenes include marquee, highlighting the cell when the mouse moves over.
Functions
The API manual is divided into two modules, public module and private module. The interfaces under public module are available to both dashboard and general report, while the interfaces under private module can only be used for the corresponding report type.
Public module, according to the elements to which interfaces apply, includes report global interface, parameter pane interface, widget interface, table interface, toolbar interface, and report pagination export.
Private module contains dashboard, general report and FVS report. General report lists the interfaces supported in different preview modes respectively. Dashboard distinguish the interfaces based on the type of components, while the interfaces in FVS report only take effect under FVS editing mode.
For details about all interfaces, see API interface summary.
Instructions
There are two ways to obtain the specified object through interfaces. 1. You can obtain the report object through the global interface, and then operate the report globally using the method of the report object. 2. You can obtain the report object through the global interface first, then obtain an object in the report object, and continue to obtain objects using the methods of the object. The way is hierarchical, that is, it has the inheritance of methods in JS.
For example. if you want to hide the Drop-down Box widget comboBox0 on the parameter pane, that is, set the widget comboBox0 to be invisible, you need to:
1. Use the _g() global interface to obtain the report object.
2. Use the getParameterContainer method of _g() to get the parameter pane object, because if you want to obtain the widget on the parameter pane, you must obtain the parameter pane first.
_g().getParameterContainer
3. Use the getWidgetByName interface of the parameter pane to obtain the Drop-down Box widget.
_g().getParameterContainer().getWidgetByName("comboBox0")
4. Use the setVisible method of the widget to set the widget to be disabled and hidden. Then you will get the JS statement for setting the widget to be disabled on the parameter pane.
_g().getParameterContainer().getWidgetByName("comboBox0").setVisible(false);
Usage in templates
If you want to use interfaces in a template, you simply need to add the code to the JavaScript script.
For example, adding the above code in section "Instructions" making the Drop-down Box widget hidden in the click event of a button widget.
Save the template and click Preview. Then you can click the button to hide the Drop-down Box widget.
Usage in Web Page
When developing a report, you can also call the JS interface provided by FineReport in a customized web page.
1. If the report is embedded in the iframe a web page, you need to obtain the iframe object first through document.getElementById (id of the iframe where the report is located), then obtain the contentWindow, and finally use the interface.
For example, when the ID of the report embedded in the iframe is reportFrame,the code to call the entry and submitting interface of the report is as follows:
document.getElementById('reportFrame').contentWindow._g().writeReport();
You will obtain the iframe object throughdocument.getElementById('reportFrame'), and then obtain the report object through _g(), and finally use the entry and submitting interface writeReport().
For details, see Custom Submit Button.
2. If you want to use the method on the FineReport object, you need to import the fineReport.js file of FineReport first. The code to use the popup dialog method of the FineReport object after importing is as follows:
<script type="text/javascript" src="/webroot/decision/view/report?op=emb&resource=finereport.js"></script>
<script>
function button_onclick(){
FR.showDialog("Test", 600, 400, "Hello World")
}
</script>