I. Overview
1.1 Requirement
In Pagination Preview and Data Entry Preview modes, users can choose report alignment options. While in Data Analysis Preview mode, the report is aligned to the left by default and users cannot make other alignment options. How to make the report centrally aligned in Data Analysis Preview mode?
1.2 Solution
In Data Analysis mode, add a Loading End event to center the report.
II. Sample
2.1Add an event
Open the template, click [Template] >[Web Attributes] >[Data Analysis Settings], and check [Individually set for the template]. In the [Event Settings], add a Loading End event. See the demonstration below:
Input the following JavaScript codes:
ms = $('.html-content').length;// Define whether there are many sheets
if (ms != 0){
//There are many sheets
ff=$(".frozen-table",$('.html-content:visible')).length// Define whether the current sheet is frozen
if (ff == 0) {
//Not frozen
var slmargin = ($(".content-container").width()-$(".sheet-container div:first-child",$('.html-content:visible')).width())/2;
if (slmargin > 0) {
$('.sheet-container',$('.html-content:visible')).css('margin-left',slmargin);//
$(".x-table",$('.html-content:visible')).css('left',slmargin);
$(window).resize();
}
}else {
//Frozen
var slmargin=($(".content-container").width()-$('.x-table',$('#frozen-center'),$('.html-content:visible')).width()-$('.x-table',$('#frozen-west'),$('.html-content:visible')).width())/2;
if (slmargin > 0) {
$('.sheet-container',$('.html-content:visible')).css('margin-left',slmargin);
$(window).resize();
}
}
}else {
ff=$(".frozen-table").length// Define whether the current sheet is frozen
//There is a single sheet
if (ff == 0) {
// The sheet is not frozen
slmargin = ($(".content-container").width() - $(".sheet-container div:first-child").width()) /2;
if (slmargin > 0) {
$('.sheet-container').css('margin-left',slmargin);//
$(".x-table").css('left',slmargin);$(window).resize();
}
}else {
//The sheet is frozen
slmargin=($(".content-container").width()-$('.x-table',$('#frozen-center')).width()-$('.x-table',$('#frozen-west')).width())/2;
if (slmargin > 0) {
$('.sheet-container').css('margin-left',slmargin);$(window).resize();
}
}
}
2.2 Preview
Save the template and click [Data Analysis Preview]. The preview effect on a PC is shown as below: