JS实现jasperreport交叉报表输出页面居中效果
function loadReportPage(url){$("#reportContent").load(url,function(){adjustReportHTML();//TODO });}//重新布局载入的报表内容html代码function adjustReportHTML(){try { var $table = $("#reportContent table:eq(0)"); var $headerTR = $("#reportContent tr:eq(0)"); var headerTdCount = $headerTR.find("td").length; var $firstInnerTR = $("#reportContent tr:eq(2)"); var firstInnerTd = $firstInnerTR.find("td:last-child"); //设置报表table宽度 var tableOldWidth = $table.css('width').replace("px",""); var reduceWidth = firstInnerTd.css('width').replace("px",""); var tableNewWidth = tableOldWidth - reduceWidth; tableNewWidth = tableNewWidth<500 ? 500 : tableNewWidth; $table.css('width',tableNewWidth); //设置报表内容空白区域TD宽度 var colspan = firstInnerTd.attr("colspan"); $("td[colspan='"+colspan+"']").each(function(index){ $(this).css("width",colspan+"px"); }); //设置报表标题区域空白TD宽度 for(var i=1;i<=3;i++){ var resetIndex = headerTdCount-i; $headerTR.find("td:eq("+ resetIndex +")").css("width","1px"); }} catch (e) {}}
?