示例说明
在灵活分析中对于跳转字段部分添加跳转链接,跳转字段为"CategoryName" 字段别名为“产品类别” 中的 ‘点心’才跳转 如下图:
设置方法
- 在资源定制中,创建一张灵活分析(带合计行)。
- 选中灵活分析,右键选择 编辑宏 进入报表宏界面
- 在报表宏界面新建客户端模块,在弹出的新建模块对话框中选择对象为simpleReport;事件为onRenderTable;并把下面宏代码复制到代码区域。
宏类型
类型 | 对象 | 事件 |
ClientSide | simpleReport | onRenderTable |
宏代码
function main(simpleReport, simpleReportContext) { //simpleReport.addColumnLinkByName("CategoryName", me); //字段别名:产品类别 var col = simpleReport.getFieldIndexByName("CategoryName"); var count = simpleReport.grid.getRowCount(); for (var i = simpleReport.grid.getHeaderRows(); i < count; i++) { var cell = simpleReport.grid.getCell(i, col); if (cell.innerHTML == "点心") { simpleReport.addCellLink(i, col, me); } else { //break; } } } var menuItem = { alias: "跳转本身", callback: function(simpleReport, simpleReportContext) { simpleReport.writeParamsToContext(); var paramsInfo = new Array(); //获取ssss参数值 var pObj = simpleReportContext.get("ssss"); var paramInfo = createParamInfo("ssss", pObj.value, pObj.displayValue); paramsInfo.push(paramInfo); //在新窗口打开资源 simpleReportContext.openURL("openresource.jsp?resid=I402881f805335152014b05468b98009f&showtoolbar=true&refresh=true", [{ name: "paramsInfo", value: lang.toJSONString(paramsInfo) }]); } } var me = menuItem; //创建参数信息 function createParamInfo(name, value, disValue) { var paramInfo = new Object(); paramInfo.name = name; paramInfo.value = value; paramInfo.displayValue = disValue; return paramInfo; }
关键对象总结
- 通过参数名获取参数对象:simpleReport.addCellLink(i, col, me)
- 打开灵活分析:simpleReportContext.openReport("I2c949eaf1a942102011a9561f7e7015d");