excel报表开发工具FineReport自定义翻页按钮

 时间:2024-10-14 21:00:10

1、自定义翻页按钮由自定义工具栏按钮章节可以知道,如上图中的首页、上一页、下一页、末页按钮,直接调用FR内置方法即可,如下首页按钮:<buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoFirstPage()">首页</button>其它上一页、下一页、末页按钮分别对应于方法gotoPreviousPage()、gotoNextPage()、gotoLastPage()。

2、页码显示如上兔脒巛钒图显示当前报表所在页与报表总页数,获得报表contentPane后可以通过contentPane.currentPageIndex及contentPane.reportTotal霸烹钟爷Page来获取当前所在页与总页数。由于页码需要在报表加载完后才能够获得,且翻页后当前页码也要随之变化,因此我们在contentPane的加载结束后监听afterload事件中将页码信息赋给文本框。functionafterload(){//iframe加载后触发varcontentPane=document.getElementById("reportFrame").contentWindow.contentPane;//获取报表contentPanevarcPageIndex=contentPane.currentPageIndex;//当前所在页varpv="第"+cPageIndex+"页/共"+contentPane.reportTotalPage+"页";//报表首次加载结束后显示的页码信息document.getElementById("page").value=pv;//将页码信息赋给page文本contentPane.on("afterload",function(){//报表加载结束监听事件cPageIndex=contentPane.currentPageIndex;//每次加载完后重新获取当前页码pv="第"+cPageIndex+"页/共"+contentPane.reportTotalPage+"页";//重新生成页码信息document.getElementById("page").value=pv;//重新给page文本赋页码信息});}

3、跳转到指定页如上图实现输入某个数字后,点击后面的“跳转”就跳到文本框中写的那页。给“跳转”加上点击事件gotopage,在js中获取文本框中输入的页码,通过contentpane.gotoPage(parseInt(num)) 跳转到指定页。注:gotoPage()中的参数必须是数值型的,而文本框中输入的为字符串,因此需要使用parseInt()将其转为数值。functiongotopage(){varcontentpane=document.getElementById('reportFrame').contentWindow.contentPane;varpage=document.getElementById("index").value;if(page>=contentpane.reportTotalPage){contentpane.gotoLastPage();}contentpane.gotoPage(parseInt(page));}

4、示例完整代码<html><head><title>自定义浏览页面</t足毂忍珩itle><scripttype="text/javascript">functionafterload(){//iframe加载后触发varcontentPane=document.getElementById("reportFrame").contentWindow.contentPane;//获取报表contentPanevarcPageIndex=contentPane.currentPageIndex;//当前所在页varpv="第"+cPageIndex+"页/共"+contentPane.reportTotalPage+"页";//报表首次加载结束后显示的页码信息document.getElementById("page").value=pv;//将页码信息赋给page文本contentPane.on("afterload",function(){//报表加载结束监听事件cPageIndex=contentPane.currentPageIndex;//每次加载完后重新获取当前页码pv="第"+cPageIndex+"页/共"+contentPane.reportTotalPage+"页";//重新生成页码信息document.getElementById("page").value=pv;//重新给page文本赋页码信息});}functiongotopage(){varcontentpane=document.getElementById('reportFrame').contentWindow.contentPane;varpage=document.getElementById("index").value;if(page>=contentpane.reportTotalPage){contentpane.gotoLastPage();}contentpane.gotoPage(parseInt(page));}</script></head><body><divid="toolbar"><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoFirstPage()">首页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoPreviousPage()">上一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoNextPage()">下一页</button><buttontype="button"onclick="document.getElementById('reportFrame').contentWindow.contentPane.gotoLastPage()">末页</button><inputid="page"type="text"readonly="true"size="12"style="border:none">到<inputid="index"type="text"size="3"/>页<aonclick="gotopage()"href="javascript:void(0)">跳转</a></div><iframeid="reportFrame"onload="afterload()"src="../ReportServer?reportlet=/doc/Primary/DetailReport/Details.cpt&__showtoolbar__=false"width=100%height=80%></iframe></body></html>由于用户自定义工具栏,显示报表时不需要显示FR内置工具栏,因此在报表url后面加上&__showtoolbar__=false。已完成示例请查看%FR_HOME%\WebReport\page_demo\gpPage.html

  • 使用Power Query合并多个规范工作簿中的数据表
  • execl中如何判断单元格里是否包含指定文本2方法
  • 怎么给excel数据透视表更换模板
  • excel中利用phonetic函数将多个单元格内容合并
  • Excel如何定位空值单元格
  • 热门搜索
    关于感恩父母的手抄报 书香满校园手抄报 清明节手抄报题目 中秋节手抄报大全 廉洁教育手抄报 五一手抄报大全 八礼四仪手抄报内容 读书手抄报大全 读书节手抄报图片 手抄报的装饰花边