创建一个数据集Constractor sql如:
select top 30 FNumber,FName,FPrincipal,FPrincipalPhone
from D_Contractor
创建报表参数principal:字段串类型,不是必需的
下面为数据集Constractor 编写脚本了:
如上图上:在beforeOpen中编写如下 代码:
var principal = BirtStr.trim(params["principal"]);
if(principal!=null && principal!=""){
this.queryText = this.queryText+" where FPrincipal like '%"+principal+"%'";
}
测试后在前台中输入参数了:
这样就可以把报表参数动态的加入到数据集的查询过程了。
注意: 这是有sql注入的风险的。所以要对参数进行严格把关
参数可以通过上面的对话框输入,也可以直接写在url中如:
http://localhost:8080/birt/frameset?__report=report_3.rptdesign&principal=【参数值】