I have created an XtraReport which has 5 subreports.
This report is quite large which consist of 10000 pages. While the report is being generated if I close the browser's tab the report is still generating in the background whereas if I click the progress bar's cancel button the report generation process is abandoned.
My question is how can I stop the report generation when I close the browser's tab?
I have seen how it does in their online demos. In short, you can do this on the window events beforeunload, focus, blur. Code from demos.devexpress.com/MVCxReportDemos:
(function() {
var doWithViewer = function(func) {
var viewer = window['webDocumentViewer'];
viewer && func(viewer);
};
var stopTimeout;
window.addEventListener("focus", function() { stopTimeout && clearTimeout(stopTimeout); });
window.addEventListener("blur", function() {
stopTimeout && clearTimeout(stopTimeout);
stopTimeout = setTimeout(function() {
doWithViewer(function(viewer) {
var reportPreview = viewer.GetReportPreview();
reportPreview && reportPreview.documentBuilding() && reportPreview.stopBuild();
});
}, 3000);
});
window.addEventListener("beforeunload", function() {
doWithViewer(function(viewer) {
setTimeout(function() { viewer.Close(); }, 1);
});
});
})()