示例说明
在灵活分析的表头添加跑马灯效果。
参考导入的XML资源:migrate.xml
设置方法
- 在资源定制中,创建一张灵活分析;
- 选中灵活分析,右键选择 编辑宏 进入报表宏界面。
- 在报表宏界面新建客户端模块,在弹出的新建模块对话框中选择对象为simpleReport;事件为onRender;并把下面宏代码复制到代码区域。
宏类型
类型 | 对象 | 事件 |
---|---|---|
ClientSide | simpleReport | onRender |
宏代码
function main(simpleReport, simpleReportContext) { simpleReport.setHeader = function() { setTitle(simpleReport); }; }; function setTitle(simpleReport) { debugger; var a = simpleReport.grid.getCell(1, 1); var avalue = a.innerText; var b = simpleReport.grid.getCell(1, 2); var bvalue = b.innerText; var c = simpleReport.grid.getCell(1, 3); var cvalue = c.innerText; var m = simpleReport.grid.getCell(2, 0); var mvalue = m.innerText; var n = simpleReport.grid.getCell(3, 0); var nvalue = n.innerText; var t = simpleReport.grid.getCell(4, 0); var tvalue = t.innerText; var tailHTML = ""; var tailHTMLHeader = ""; if (domutils.isIOS()) { tailHTMLHeader += "<font style='color:#06C; font-size:16px; font-weight:bold;'>"; tailHTML += "<div style='margin:0px 10px; height:50px; padding:5px;'><marquee direction='up' scrollamount='1' onTouchStart='this.stop()' onTouchEnd='this.start()' width='400px' height='50px'>"; } else { tailHTMLHeader += "<font style='color:#000; font-size:16px; font-weight:bold;'>"; tailHTML += "<div style='margin:0px 0px; padding:5px;'><marquee direction='up' scrollamount='1' onmouseover='this.stop()' onmouseout='this.start()' width='500px' height='35px'>"; } for (var m = 1; m < 2; m++) { var txt = "销售区域共有8条记录,其中销售额总计为:<font color='#FF0000'>" + avalue + "</font>;销售量总计:<font color='#FF0000'>" + bvalue + "</font>;</br>运费总计为:<font color='#FF0000'>" + cvalue + "</font>。其中销售额排名前三位的产品为:<font color='#FF0000'>" + mvalue + "、" + nvalue + "、" + tvalue + " </font>。"; // alert(txt); if (domutils.isIOS()) { tailHTML += "<span style='font-size:16px; color:#FFFFFF; line-height:20px; height:20px;'>"; } else { tailHTML += "<span style='font-size:12px; color:#000000; line-height:18px; height:20px;'>"; } //tailHTML += "<table><tr>"; if (domutils.isIOS()) { tailHTML += "<td style='width:120px; text-align:left; font-size:16px; color:#FFFFFF; line-height:20px; height:20px;'>" + txt + "</td>"; } else { tailHTML += "<td style='width:120px; text-align:left; font-size:16px; color:#000000; line-height:20px; height:20px;'>" + txt + "</td>"; } // tailHTML += "</tr></table></span><br/>"; } //tailHTML += " </marquee></div> "; simpleReport.reportHeader.innerHTML = tailHTMLHeader + tailHTML; // simpleReport.reportTail.innerHTML = tailHTML; };
关键对象总结
- 读取表内容:simpleReport.setHeader
- 读取单元格内容:simpleReport.grid.getCell(int,int)
- 读取表格列:simpleReport.getFieldIndexByAlias(string)
- IPAD上响应鼠标事件:onTouchStart(this.stop()) onTouchEnd(this.start())
- PC上响应鼠标事件:onmouseover () onmouseout ()