提示:本文档的示例代码仅适用于本文档中的示例报表/场景。若实际报表/场景与示例代码无法完全适配(如使用功能不一致,或多个宏代码冲突等),需根据实际需求开发代码。 |
在灵活分析中切换一个参数,不同的参数值打开不同的报表。如下图:
切换【报表】参数,值为1的时候显示报表1:
切换【报表】参数,值为2的时候显示报表2:
切换【报表】参数,值为3的时候显示报表3:
宏类型
类型 | 对象 | 事件 |
ClientSide | simpleReport | onParamValueChanged |
宏代码
function main(simpleReport, simpleReportContext, param) { var destQuery = null; if (param.name == "报表") { if (param.value == 1) destQuery = simpleReportContext.openReport('I4028818a2578cab101522681313b0183'); //报表1的ID else if (param.value == 2) destQuery = simpleReportContext.openReport('I4028818a2578cab10152268375b10228'); //报表2 的ID else destQuery = simpleReportContext.openReport('I4028818a2578cab1015226845cfd0273'); //报表3的ID realValue = param.value dispValue = param.displayValue; if (realValue && dispValue) destQuery.fillParamValue('报表', realValue, dispValue); destQuery.refreshData(); } } |
关键对象总结
资源下载:migrate根据参数值不同显示不同的报表.xml