数据报表FineReport中如何设置自定义缩放按钮
1、我们使用模板FR_HOME%\WebReport\WEB-INF\reportlets\doc\Advanced\Chart\Bubble.cpt来作为内嵌iframe。
首先定义javascript代码触发放大缩小的功能,代码如下:
<script type="text/javascript">
function afterload(){
document.getElementById('reportFrame').contentWindow.contentPane.scale('-');
fuzhi();
}
function afterload2(){
document.getElementById('reportFrame').contentWindow.contentPane.scale('+');
fuzhi();
}
function fuzhi() 科罩
{
var contentPane = document.getElementById("reportFrame").contentWindow.contentPane;
var zoom = contentPane.zoom * 100 +"%";
document.getElementById("zoom").value = zoom; //将新的显示百分比赋给zoom文本框
}
</script>
2、其次在body里面直接调用js里面定义好的方法,代码如下:
<body onload="fuzhi()">
<始国凤div id="toolbar">
<input type="button" onclick="afterload();" value="-"></input>
<input id="zoom" type="text" readonly="true" style="width: 80px">
<input type="button" onclick="afterload2();" value="+"></input>
</div>
3、完整代码如下
<html>
<head>
<title>FineReport Demo</title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
</head>
<script type="text/javascript">
function afterload(){
document.getElementById('reportFrame').contentWindow.contentPane.scale('-');
fuzhi();
}
function afterload2(){
document.getElementById('reportFrame').contentWindow.contentPane.scale('+');
fuzhi();
}
function fuzhi()
{
var contentPane = document.getElementById("reportFrame").contentWindow.contentPane;
var zoom = contentPane.zoom * 100 +"%";
document.getElementById("zoom").value = zoom; //将新的显示此屈百分比赋给zoom文本框
}
</script>
<body>
<iframe id="reportFrame
<body onload="fuzhi()">
<div id="toolbar">
<input type="button" onclick="afterload();" value="-"></input>
<input id="zoom" type="text" readonly="true" style="width: 80px">
<input type="button" onclick="afterload2();" value="+"></input>
</div>
</body>
</html>
4、效果如下
