Kode_12 Kode_12 - 3 months ago 21
Javascript Question

How can I find the results of a search field using a Filter "EQ" method?

I have an Input element that acts as a search field. The function below filters the user input against the scope's data after they submit the search.

My question is: How can I locate the results from the filtering? For instance, say a user enters a valid product, but the data shows no history of it--I would like to have a way where I can notify a user (ie: an alert) if the submitted query results in no matches from the data?

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


I don't know where to find this inside the 'aFilter' array.

Here is an example if it will help


You can use oBinding.getLength() to get the number of entries in the list binding after applying the filter. In your case 0 would be returned. Another way is to call oTable.getItems() after applying the filter and it will return an empty array.