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:
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.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:
III.FR Common Methods
3.1 FR.ajax(options)
Description | Send Ajax request, specific reference (AJAX) |
---|---|
Parameters |
|
Returns | void |
3.2 FR.showDialog(title, width, height, innerContent)
Description | Show a dialog |
---|---|
Parameters |
|
Returns | void |
3.3 FR.closeDialog()
Description | Close dialog |
---|---|
Parameters | None |
Returns | void |
3.4 FR.doHyperLinkByGet(url, para, target, feature)
Description | Hyperlink, pass the parameter para to target by GET, and set the window attributes in feature. Specific reference (link) |
---|---|
Parameters |
|
Returns | void |
3.5 FR.doHyperLinkByPost(url, para, target, feature)
Description | Hyperlink, passes the parameter para to the target by POST, and sets the window attributes in the feature. Specific reference (link) |
---|---|
Parameters |
|
Returns | void |
3.6 FR.doURLPrint(config)
Description | Print,details reference (JS calls FR print method) |
---|---|
Parameters |
|
Returns | void |
3.7 FR.isArray(object)
Description | Whether the object is an array, if yes, return true, if no, return false |
---|---|
Parameters |
|
Returns | Boolean |
3.8 FR.isEmpty(object)
Description | Whether the object is empty, return true if yes, false if no |
---|---|
Parameters |
|
Returns | Boolean |
3.9 FR.jsonDecode(encodedString)
Description | Decode the string jsonEncoded |
---|---|
Parameters |
|
Returns | String |
3.10 FR.jsonEncode(decodedString)
Description | JsonEncode the string |
---|---|
Parameters |
|
Returns | String |
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 |
|
Returns | Object |
The remoteEvaluate(String) method does not support the tablename.select function.