如何使用筛选"EQ"方法查找搜索字段的结果?



我有一个Input元素作为搜索字段。在用户提交搜索后,下面的函数根据作用域的数据过滤用户输入。

我的问题是:我如何定位过滤的结果?例如,假设用户输入一个有效的产品,但数据没有显示它的历史-我想有一种方法,我可以通知用户(即:警报),如果提交的查询结果没有匹配的数据?

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);
        };
    };

我不知道在' filter '数组中找到这个

如果有帮助的话,这里有一个例子http://jsbin.com/vigeg/1/edit?js,输出

您可以使用oBinding.getLength()在应用过滤器后获得列表绑定中的条目数。在您的情况下,将返回0。另一种方法是在应用过滤器后调用oTable.getItems(),它将返回一个空数组。