Skip to Content
0

MultiInput with Odata

Mar 07, 2017 at 05:20 PM

63

avatar image
How can I consume a service Odata in the aItems?

bellow is my controller

sap.ui.controller("sap.ui.comp.sample.valuehelpdialog.example1.ValueHelpDialog", { onInit: function() { this.theTokenInput = this.getView().byId("multiInput"); this.theTokenInput1 = this.getView().byId("loginPara"); this.aKeys = ["user", "name"]; this.aItems = [{ user: "carlos", name: "Carlos Cesar" }, { user: "mario", name: "Sergio Mario" }]; }, onValueHelpRequest: function() { var that = this; var oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog({ basicSearchText: this.theTokenInput.getValue(), title: "Login", supportMultiselect: false, supportRanges: false, supportRangesOnly: false, key: this.aKeys[0], descriptionKey: this.aKeys[1], stretch: sap.ui.Device.system.phone, ok: function(oControlEvent) { that.aTokens = oControlEvent.getParameter("tokens"); that.theTokenInput.setTokens(that.aTokens); oValueHelpDialog.close(); }, cancel: function(oControlEvent) { oValueHelpDialog.close(); }, afterClose: function() { oValueHelpDialog.destroy(); } }); var oColModel = new sap.ui.model.json.JSONModel(); oColModel.setData({ cols: [{ label: "Login", template: "user" }, { label: "Nome", template: "name" }] }); oValueHelpDialog.getTable().setModel(oColModel, "columns"); var oRowsModel = new sap.ui.model.json.JSONModel(); oRowsModel.setData(this.aItems); oValueHelpDialog.getTable().setModel(oRowsModel); if (oValueHelpDialog.getTable().bindRows) { oValueHelpDialog.getTable().bindRows("/"); } var oFilterBar = new sap.ui.comp.filterbar.FilterBar({ advancedMode: true, filterBarExpanded: false, showGoOnFB: sap.ui.Device.system.phone }); var oSearch = new sap.m.SearchField({ search: function(oEvent) { var sQuery = oEvent.getParameter("query"); var oBinding = oValueHelpDialog.getTable().getBinding("rows"); if (sQuery) { var oFilter1 = [new sap.ui.model.Filter("user", "Contains", sQuery), new sap.ui.model.Filter("name", "Contains", sQuery)]; var allFilters = new sap.ui.model.Filter(oFilter1, false); oBinding.filter(allFilters); } else { var oFilter = new sap.ui.model.Filter("user", sap.ui.model.FilterOperator.Contains, sQuery); oBinding.filter(oFilter); } } }); oFilterBar.setBasicSearch(oSearch); oValueHelpDialog.setFilterBar(oFilterBar); oValueHelpDialog.open(); } });
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Srikanth KV Mar 07, 2017 at 05:45 PM
0

Create oData Model, then replace your JSON model with oData model and perform necessary binding

Show 1 Share
10 |10000 characters needed characters left characters exceeded

I don't know how can I do it.

I have to consume a OData service like this

Can you show me a example? or Help me to do it?

0