gpt4 book ai didi

javascript - 如何使用 Filter "EQ"方法查找搜索字段的结果?

转载 作者:太空宇宙 更新时间:2023-11-04 16:23:58 27 4
gpt4 key购买 nike

我有一个充当搜索字段的输入元素。下面的函数在用户提交搜索后根据范围数据过滤用户输入。

我的问题是:如何找到过滤结果?例如,假设用户输入了有效的产品,但数据没有显示它的历史记录 - 我希望有一种方法,如果提交的查询结果与搜索结果不匹配,我可以通知用户(即:警报)数据?

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

最佳答案

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

关于javascript - 如何使用 Filter "EQ"方法查找搜索字段的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40386620/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com