我有一个作为搜索字段的输入元素。下面的函数根据用户提交搜索后的范围数据过滤用户输入。
我的问题是:如何定位过滤的结果?例如,假设一个用户输入了一个有效的产品,但是数据没有显示它的历史记录--我想有一种方法,如果提交的查询结果与数据不匹配,我就可以通知用户(例如:警报)?
onFilterProduct : function (oEvent) {
// build filter array
var aFilter = [],
//get the searchfield Id
oInput = this.byId("productSearch"),
oTable = this.getView().byId("idProductsTable"),
oBinding = oTable.getBinding("items"),
//get searchfield value
sQuery = oInput.getValue(),
if (sQuery) {
//push matches into aFilter array
aFilter.push(new Filter("Product", FilterOperator.EQ, sQuery));
oBinding.filter(aFilter);
};
};我不知道在'aFilter‘数组中如何找到这个。
下面是一个示例,如果它将帮助http://jsbin.com/vigeg/1/edit?js,output
发布于 2016-11-02 18:53:06
应用筛选器后,可以使用oBinding.getLength()获取列表绑定中的条目数。在您的情况下,0将被返回。另一种方法是在应用过滤器之后调用oTable.getItems(),它将返回一个空数组。
https://stackoverflow.com/questions/40386620
复制相似问题