反饋已提交

網絡繁忙

自定义翻页按钮

1. 概述

1.1 问题描述

用户将网页中的一部分嵌入了一张报表模板,有时希望能够自己定义翻页按钮,不使用报表已有的按钮,如下图所示:

1600935266984804.png

1.2 实现思路

由 自定义按钮 章节可知,如上图中的首页、上一页、下一页、末页按钮,直接调用 FR 内置方法即可

  • 首页按钮调用方法:gotoFirstPage()

  • 上一页按钮调用方法:gotoPreviousPage()

  • 下一页按钮调用方法:gotoNextPage()

  • 末页按钮按钮调用方法:gotoLastPage()

获取当前所在页与总页数对应方法「contentPane.currentPageIndex及 「contentPane.reportTotalPage」

2. 操作步骤

2.1 新建 HTML 文件

1)新建goPage.html,内容如下:

点击下载文件:goPage.zip

<html>     
  <head>     
  <title>自定义翻页按钮</title>  
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />     
  <script type="text/javascript">     
    function afterload() {     //iframe 加载后触发
      var contentPane = document.getElementById("reportFrame").contentWindow._g();  //获取报表 contentPane   
      var cPageIndex = contentPane.currentPageIndex;   //当前所在页
      var pv = "第" + 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 文本赋页码信息   
      });      
    }     
  function gotopage() {     
    var contentpane= document.getElementById('reportFrame').contentWindow._g();     
    var page = document.getElementById("index").value;     
    if(page >= contentpane.reportTotalPage) {     
      contentpane.gotoLastPage();     
    }      
    contentpane.gotoPage(parseInt(page));     
  }     
</script>     
</head>   
<body>     
  <div id="toolbar">     
    <button type="button" onclick="document.getElementById('reportFrame').contentWindow._g().gotoFirstPage()">首页</button>     
    <button type="button" onclick="document.getElementById('reportFrame').contentWindow._g().gotoPreviousPage()">上一页</button>      
    <button type="button" onclick="document.getElementById('reportFrame').contentWindow._g().gotoNextPage()">下一页</button>       
    <button type="button" onclick="document.getElementById('reportFrame').contentWindow._g().gotoLastPage()">末页</button>
    <input id="page" type="text" readonly="true" size="12" style="border:none">     
    到<input id ="index" type ="text" size="3"/>页 <a onclick="gotopage()" href="javascript:void(0)">跳转</a>
  </div>     
  <iframe id="reportFrame" onload="afterload()" src="../../decision/view/report?viewlet=/doc/Primary/DetailReport/Details.cpt&__showtoolbar__=false" width =100% height =80%></iframe>     
</body>     
</html> 

2)goPage.html放置到 %FR_HOME%\webapps\webroot\help\page_demo 路径下。

2.2 效果预览

启动工程,在浏览器输入:http://localhost:8075/webroot/help/page_demo/goPage.html ,效果如下图所示:

222




附件列表


主題: 原简体文档
  • 有幫助
  • 沒幫助
  • 只是瀏覽
  • 圖片不清晰
  • 用語看不懂
  • 功能說明看不懂
  • 操作說明太簡單
  • 內容有錯誤
中文(繁體)

滑鼠選中內容,快速回饋問題

滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

不再提示

10s後關閉

獲取幫助
線上支援
獲取專業技術支援,快速幫助您解決問題
工作日9:00-12:00,13:30-17:30在线
頁面反饋
針對當前網頁的建議、問題反饋
售前咨詢
業務咨詢
電話:0933-790886或 0989-092892
郵箱:taiwan@fanruan.com
頁面反饋
*問題分類
不能為空
問題描述
0/1000
不能為空

反馈已提交

网络繁忙