birt 报表设计(9)— 报表参数

建立一个数据集Constractor sql如: sql


select top 30 FNumber,FName,FPrincipal,FPrincipalPhone 
from D_Contractor


建立报表参数principal:字段串类型,不是必需的 测试


下面为数据集Constractor 编写脚本了: this

如上图上:在beforeOpen中编写以下 代码: url


var principal = BirtStr.trim(params["principal"]);
if(principal!=null && principal!=""){
	this.queryText = this.queryText+" where FPrincipal like '%"+principal+"%'";
}


测试后在前台中输入参数了: spa

这样就能够把报表参数动态的加入到数据集的查询过程了。 code

注意: 这是有sql注入的风险的。因此要对参数进行严格把关 ip

参数能够经过上面的对话框输入,也能够直接写在url中如: ci

http://localhost:8080/birt/frameset?__report=report_3.rptdesign&principal=【参数值】 class

相关文章
相关标签/搜索