JS API

  • Last update:  2023-04-17
  • 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.

    JS API.png

    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.

    2.png

    Save the template and click Preview. Then you can click the button to hide the Drop-down Box widget.

    3.gif


    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>

    Attachment List


    Theme: Secondary Development
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy