定时刷新页面中的皕杰报表实例

局部刷新页面中的皕杰报表实例

皕杰报表本身没有定时刷新功能,皕杰报表在web端可以加载到iframe中显示,那我们就可以用js刷新iframe来实现定时刷新。

<!--[if !supportLists]-->1.<!--[endif]-->准备一个测试报表,报表名为dssx,为了数据实时性,我获取系统日期来生成测试数据并生成图表



 

图表设计



 

<!--[if !supportLists]-->2.<!--[endif]-->将这个brt放到web应用下 WEB-inf/reports目录下(web端配置的报表存放根目录)。

<!--[if !supportLists]-->3.<!--[endif]-->修改config.xml里的runmode节点值为develop(开发模式,不启用报表缓存功能,实时刷新数据和报表模板,方便开发调试。)

<!--[if !supportLists]-->4.<!--[endif]-->web应用下创建一下新的html,内容如下:

<html>

         <head>

                  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">    

扫描二维码关注公众号,回复: 6317189 查看本文章

                  <style>

                           body{ text-align:center}

                           #rpt_div{margin:0 auto;border:1px solid #000;}

                  </style>

                  <script language="javascript">

                  var chatIframeTimer = setInterval("chatIframeReload()",5000);//10001秒钟

                  function chatIframeReload()

                  {       

                           document.getElementById('params_tbl').contentWindow.location.reload(true);

                  }

                  function chatIframeStop()

                  {

                           if(chatIframeTimer)

                           {

                                    window.clearTimeout(chatIframeTimer);

                           }

                  }                                                    

                  </script>

         </head>

         <body  style="margin:10px;">

         <div id="rpt_div1"><H1>局部刷新测试2019-5-27</H1>

         <p><button type="button" onclick='chatIframeReload()'>开始刷新</button>&nbsp;&nbsp;&nbsp;<button type="button" onclick='chatIframeStop()'>结束刷新</button></p>

         </div>

                  <div id="rpt_div" style='width:600px;height:400px'>

                  <iframe id="params_tbl"  src="ReportEmitter?rpt=dssx.brt" scrolling="auto" style='width:100%;height:100%' frameborder="0" />

                  </div>

         </body>

</html>

 

<!--[if !supportLists]-->5.<!--[endif]-->启动报表web应用并访问这个html文件。

 

点击 开始刷新按钮



 

每过5秒皕杰报表所在div就刷新一次,并且表格数据和图表中的数据一致。

 

猜你喜欢

转载自raq.iteye.com/blog/2441489
今日推荐