本例繼續(xù)接著上一個(gè)報(bào)表制作,所以之前的準(zhǔn)備工作此文略,詳見(jiàn):
BIRT--帶查詢(xún)和過(guò)濾功能的報(bào)表
1. 為下拉菜單建立數(shù)據(jù)集
a. 新建數(shù)據(jù)集“areaList”,
SQL: select area
from product
union
select 'all' from product.
2. 修改“Report Parameter”
a. 在“Report Parameter”中右擊“area”參數(shù)。
b. 在“Display Type”中選擇“List Box”。
c. 在“Date Set”中選擇剛建好的“areaList”。
d. 其它參數(shù)如下圖
3. 為選項(xiàng)“All”定義查詢(xún)。為了使當(dāng)用戶(hù)選擇了“All”時(shí)能顯示全部數(shù)據(jù),需要對(duì)它單獨(dú)寫(xiě)腳本
a. 在中間的“Layout”視圖,點(diǎn)一下頁(yè)面。
b. 然后,選擇“Script”視圖。
c. 在上方選擇“before Factory”選項(xiàng)。
d. 寫(xiě)入如下腳本:
if(params["area"] == "all"){
sql = "select * from product where '1' != ?";
this.getDataSet("product").queryText = sql;
}
4. 切換到“Preview”視圖查看效果。
眼鏡蛇