I. Overview
1. Application Scenario
The engine-X preview can effectively solve the problem of slow template preview, but it is still relatively slow when exporting datasets.
2. Implementation ideas
Exporting datasets is slow, mainly because all templates need to be calculated before exporting, so as long as the engine-X supports exporting large datasets, it will be fine.
By customizing a button on the toolbar and entering custom JS events, the export of large datasets can be realized, which can significantly improve the export speed.
Note: This method works for cpt templates that use the engine-X.
II. Example
1. Custom button
1) Open the template: %FR_HOME%\webroot\WEB-INF\reportlets\demo\NewbieGuide\line report.cpt, the template uses the new calculation engine, see the document for the method: Engine-X Usage
2) Click Template > Web Attributes in the menu bar, and select Pagination Preview > Individually set for the template in the template Web attributes setting interface, as shown in the following figure:
3) Add a custom button to the toolbar, click the edit button on the top toolbar, as shown below:
4) Rename the custom button to Large DataSet Export, click the User Defined Event button, as shown in the following figure:
5) Open the event editing interface, enter the JS code, as shown in the following figure:
The JS code looks like this:
var dsName = encodeURIComponent("ds1");
var url = "http://localhost:8075/webroot/decision/url/report/v10/direct/export" + "?sessionID=" + Report.SessionMgr.get() + "&dsName=" + dsName;
var form = $("<form>");
$("body").append(form);
if (url.indexOf('?') !== -1) {
var q = url.substr(url.indexOf('?') + 1);
var qs = q.split('&');
for (var i = 0; i < qs.length; i++) {
var p = qs[i];
var ps = p.split('=');
if (ps.length === 2) {
$('<input/>').attr('name', ps[0]).val(ps[1]).appendTo(form);
}
}
url = url.substring(0, url.indexOf('?'));
} else {
var input = $("<input>");
form.append(input);
}
form.attr({"style": "display : none", "target": "", "method": "post", "action": url});
form.submit();
form.remove();
2. Effect preview
Save the report, click the pagination preview, the export effect is as shown below:
III. Template download
The completed template can be found in: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Parameter\Engine-X DataSet Export.cpt
Click to download the template:
IV. Other instructions
1. Export with parameters
Sample template:
Drop-down box parameters linkage.zip
If the template needs to be exported with parameters, the template can be filtered by the parameters in the parameter pane. For details, please refer to: Drop-down box parameter linkage
The custom button settings are shown below:
Other steps are the same as in Chapter II of this article, and the code is shown in the following figure:
var dsName = encodeURIComponent("ds1");
var url = "http://localhost:8075/webroot/decision/url/report/v10/direct/export" + "?sessionID=" + Report.SessionMgr.get() + "&dsName=" + dsName + "&area=" + a + "&province=" + b + "&city=" + c ;
var form = $("<form>");
$("body").append(form);
if (url.indexOf('?') !== -1) {
var q = url.substr(url.indexOf('?') + 1);
var qs = q.split('&');
for (var i = 0; i < qs.length; i++) {
var p = qs[i];
var ps = p.split('=');
if (ps.length === 2) {
$('<input/>').attr('name', ps[0]).val(ps[1]).appendTo(form);
}
}
url = url.substring(0, url.indexOf('?'));
} else {
var input = $("<input>");
form.append(input);
}
form.attr({"style": "display : none", "target": "", "method": "post", "action": url});
form.submit();
form.remove();