Skip to Content

MultiInput with Odata

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(); } });
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Mar 07, 2017 at 05:45 PM

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

    Add comment
    10|10000 characters needed characters exceeded