【Finereport】限制控制元件引數不為空
阿新 • • 發佈:2018-12-17
在報表開發時,出於合規化和資料量的原因,會要求某些篩選項控制元件不為空,總結了以下幾種方法:
1.控制--屬性
屬性→檢驗→去掉允許為空→錯誤資訊(填寫提示語)
2.Search控制元件--點選事件
Search控制元件(查詢)→事件→新增點選事件→JS編碼
var Widget = this.options.form.getWidgetByName("員工姓名"); var name=Widget.getValue(); var Widget = this.options.form.getWidgetByName("客戶id"); var clientid=Widget.getValue(); if(name.length==0&&clientid==0) {alert("請輸入任一特定資訊:員工姓名、客戶id!"); return false;}
3.資料集--sql中判斷
(函式寫得很拙劣,大家別介意)
select *
from test
where
1=1
${if(or(len(員工姓名)>0, len(客戶id)>0),if(len(員工姓名)>0, "and name='"+客戶姓名+"'", ""), "and name= ''")}
${if(or(len(員工姓名)>0, len(客戶id)>0),if(len(客戶id)>0, "and clientid='"+客戶id+"'", ""), "and clientid= ''")}