Successfully!

Error!

FR Object

  • Last update:  2020-12-23
  • I.Overview

    When previewing the report, the report servlet will convert the cpt template to HTML, and FR JavaScript will be introduced in the head of the HTML, as follows:

    <script type="text/javascript" src="/webroot/decision/view/report?op=emb&resource=finereport.js"></script>

    This finereport.js contains many built-in functions and some public attributes. Whether in the template or other web pages, as long as finereport.js is introduced, the public attributes and methods can be called in the form of FR.xxx.

    FR objects can be obtained in all places including webpage events, widget events, hyperlink JavaScript, and decision report events.

    II.Use Cases

    2.1 Use In the Template

    Finereport.js is automatically introduced when accessing the template, so FR.xxx can be used directly to call the method in the JavaScript script of the template.

    2.1.1 Add Event

    Here, taking the dialog box as an example, add a "click" event to the widget and edit the JavaScript script, as shown in the following figure:

    1.png

    code is shown below:

    FR.showDialog("CES",600,400,"CESSSS")

    2.1.2 Effect Display

    Save and preview in data entry mode, click the "Test" button on the page, a dialog box will appear, as shown below:

    2.png


    2.2 Use In the Webpage

    If the users need to call FR methods on your own webpage, they need to introduce finereport.js first, and then call it through FR.xxx.

    2.2.1 Add Code

    Same as the above example, create a new HTML file and add the following code:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
     <head>
      <title>FineReport Demo</title>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <!-- Include finereport.js -->
      <script type="text/javascript" src="/webroot/decision/view/report?op=emb&resource=finereport.js"></script>
      <!-- Include finreport.css -->
      <link rel="stylesheet" type="text/css" href="/webroot/decision/view/report?op=emb&resource=finereport.css&cssVersion=1591683351598">
     </head>
     <body>
      <input type="button" value="Test" onclick="showDialog();" />
      <script>
        function showDialog(){
          FR.showDialog("CES", 600, 400, "CESSSS");
        }
      </script>
     </body>
    </html>

    2.2.2. Effect Display

    Save the above HTML to %FR_HOME%\webapps\webroot path, use a browser to access this page, the effect is shown in the following figure:

    3.png

    III.FR Common Methods

    3.1 FR.ajax(options)

    DescriptionSend Ajax request, specific reference (AJAX)
    Parameters
    • options JSON

    • Mandatory, request parameters

    Returnsvoid


    3.2 FR.showDialog(title, width, height, innerContent)

    DescriptionShow a dialog
    Parameters
    • title: String

      •  title

    • width: Number

      • Dialog width

    • height: Number

      • Dialog height

    • innerContent: String

      • Dialog content

    Returnsvoid


    3.3 FR.closeDialog()

    DescriptionClose dialog
    ParametersNone
    Returnsvoid


    3.4 FR.doHyperLinkByGet(url, para, target, feature)

    DescriptionHyperlink, pass the parameter para to target by GET, and set the window attributes in feature. Specific reference (link)
    Parameters
    • url: String

      • Mandatory, jump the link

    • para: JSON

      • Optional, passed parameters

    • target: String

      • Optional,  the opening position of the hyperlink subpage

    • feature: JSON

      • Optional, the attributes of the hyperlink open position

    Returnsvoid


    3.5 FR.doHyperLinkByPost(url, para, target, feature)

    DescriptionHyperlink, passes the parameter para to the target by POST, and sets the window attributes in the feature. Specific reference (link)
    Parameters
    • url: String

      • Mandatory , jump the link

    • para: JSON

      • Optional , passed parameter

    • target: String

      • Optional the opening posititon of the hyperlink subpage

    • feature: JSON

      • Optional, the attributes of the hyperlink open position

    Returnsvoid


    3.6 FR.doURLPrint(config)

    DescriptionPrint,details reference (JS calls FR print method)
    Parameters
    • config: JSON

      • Manatory, print configuration

    Returnsvoid


    3.7 FR.isArray(object)

    DescriptionWhether the object is an array, if yes, return true, if no, return false
    Parameters
    • object: Object

      • some object

    ReturnsBoolean


    3.8 FR.isEmpty(object)

    DescriptionWhether the object is empty, return true if yes, false if no
    Parameters
    • object: Object

      • some object

    ReturnsBoolean


    3.9 FR.jsonDecode(encodedString)

    DescriptionDecode the string jsonEncoded
    Parameters
    • encodedString: String

      • the encoded string

    ReturnsString


    3.10 FR.jsonEncode(decodedString)

    DescriptionJsonEncode the string
    Parameters
    •  decodedString: String

      • String to be encoded

    ReturnsString


    3.11 FR.removeEvaluate(formula)

    Description Execute FR built-in formula and return the result of formula calculation. For example: var a = FR.remoteEvaluate("sum(A1,A2)") means to execute sum(A1,A2)
    Parameters
    • formula: String

      • Mandatory, specific formula

    ReturnsObject
    • The remoteEvaluate(String) method does not support the tablename.select function.


    Attachment List


    Theme: Secondary Development
    Already the First
    Already the Last
    • Helpful
    • Not helpful
    • Only read

    Doc Feedback