Hello Naoto, you are probably going to want to take your input and filter it using the SAPUI5 Filter: https://sapui5.hana.ondemand.com/#/api/sap.ui.model.Filter/overview this might be helpful. If you are interested in reading more about OData filtering, you can look into this: http://www.odata.org/getting-started/basic-tutorial/#filter
I tried this:
INPUT <Input id="cat" value="" tooltip="Ejemplo: 11111 , 22222 , A4333" submit="onSearchs"/> BOTON <Button icon="sap-icon://search" type="Default" press="onSearch"/>
In this case, be cause i was using an input and bottom you need to program the buttom and obtionaly a submit for the input so when the press Enter a event is triggered. Another important point is this don't use jquery that's why the code is little different:
Input (Event submit)
onSearchs : function(oEvent) { // build filter array var aFilter = []; // fetch event parameter var sQuery = oEvent.getParameter("value"); // Regresa la lista var oList = this.getView().byId("results"); // get binding for aggregation 'items' var oBinding = oList.getBinding("items"); if (sQuery) { aFilter.push(new Filter("CategoryName", FilterOperator.Contains, sQuery)); } // apply filter. an empty filter array will show all items oBinding.filter(aFilter); },
bottom
onSearch : function(oEvent) { // build filter array var aFilter = []; // fetch event parameter var sQuery = this.byId('cat').getValue(); // Regresa la lista var oList = this.getView().byId("results"); // get binding for aggregation 'items' var oBinding = oList.getBinding("items"); if (sQuery) { aFilter.push(new Filter("CategoryName", FilterOperator.Contains, sQuery)); } // apply filter. an empty filter array will show all items oBinding.filter(aFilter); },
As Paul Aschmann mentioned is better to use on searchfield but this is for learning purpose and that's ok
Add comment