搜索框实现时,如果直接使用filter数组,为多个查询条件的AND查询;如果需要为or查询时,需要用Filter实例化,
handleSearch(oEvent){
var aFilters = [];
// 获取输入的查询条件
var sInput = oEvent.getSource().getValue();
if (sInput && sInput.length > 0) {
// 按输入设置查询过滤
var oFilter1 = new sap.ui.model.Filter('ID', sap.ui.model.FilterOperator.Contains, sInput);
aFilters.push(oFilter1);
var oFilter2 = new sap.ui.model.Filter('Amount', sap.ui.model.FilterOperator.Contains, sInput);
aFilters.push(oFilter2);
}
// 读取List 绑定
var oBinding = this.getView().byId("List").getBinding("items");
// and
//oBinding.filter(aFilters);
// Or
//oBinding.filter(!sInput ? [] : [new sap.ui.model.filter(aFilters), false]);
}