反饋已提交
網絡繁忙
一般情况下我们将网页中的一部分嵌入了一张 FR 做的报表,图表数据比较密集,我们希望能够进行缩放,从而更加清楚地查看报表,就需要定义报表的缩放。
缩放可放大和缩小报表页面,Web 页面调用,效果如下图:
注:也可以直接在模板工具栏中添加缩放按钮。
通过 FR 内置的 JS 函数 contentPane.scale('+') 可以对报表页面进行放大,通过 contentPane.scale('-') 可以对报表页面进行缩小,再利用contentPane.zoom可以获取到当前报表显示的比例,进而实现可自定义的页面放大及缩小。
我们使用模板FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc\Advanced\Chart\Bubble.cpt 来作为内嵌 iframe。
新建一个 HTML 文件,首先定义 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>
其次在 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>
完整代码如下
<html> <head> <title>自定义缩放按钮</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </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" width="900" height="500" src="/webroot/decision/view/report?viewlet=/doc/Advanced/Chart/Bubble.cpt"></iframe> <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>
启动设计器,在浏览器输入:http://localhost:8075/webroot/help/page_demo/zoom.html,效果如下图:
已完成页面请查看%FR_HOME%/webapps/webroot/help/page_demo/zoom.html
点击下载:
zoom.html
文 檔回 饋
滑鼠選中內容,快速回饋問題
滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。
不再提示
10s後關閉