Skip to content

Instantly share code, notes, and snippets.

@maximgatilin
Created March 13, 2017 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maximgatilin/4abdc6497adafa239dd735bc73a45f02 to your computer and use it in GitHub Desktop.
Save maximgatilin/4abdc6497adafa239dd735bc73a45f02 to your computer and use it in GitHub Desktop.
Simple Filter #tags:fiori
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/ui/model/json/JSONModel",
"sap/ui/demo/wt/model/formatter",
"sap/ui/model/Filter",
"sap/ui/model/FilterOperator"
], function (Controller, JSONModel, formatter, Filter, FilterOperator) {
"use strict";
return Controller.extend("sap.ui.demo.wt.controller.InvoiceList", {
formatter: formatter,
onInit : function () {
var oViewModel = new JSONModel({
currency: "EUR"
});
this.getView().setModel(oViewModel, "view");
},
onFilterInvoices : function (oEvent) {
// build filter array
var aFilter = [];
var sQuery = oEvent.getParameter("query");
if (sQuery) {
aFilter.push(new Filter("ProductName", FilterOperator.Contains, sQuery));
}
// filter binding
var oList = this.getView().byId("invoiceList");
var oBinding = oList.getBinding("items");
oBinding.filter(aFilter);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment