Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Getting error in filtering a data in table while consuming data from odata services.

Hi,

I am Getting error in filtering a data in table while consuming data from odata services and the table lies in value help control.I am able to get data in table through odata service but when i enter the company code value in search field and press go button data in table is not updated.Kindly look into the problem.


find the attachment of the output screen.

Controller

onInit: function() {

var oDataModel = new sap.ui.model.odata.ODataModel("service url",  true, "username",  "password");

sap.ui.getCore().setModel(oDataModel,"oDataModel1");


this.theTokenInput= this.getView().byId("multiInput1");

  this.aKeys= ["CompanyCode","CompanyCodeName"];

var token1= new sap.m.Token({key: "001", text: "Construction"});

  this.aTokens= [token1];

  this.theTokenInput.setTokens(this.aTokens);


},


onValueHelpRequest: function() {

  var that= this;

  var oValueHelpDialog = new sap.ui.comp.valuehelpdialog.ValueHelpDialog({

  basicSearchText: this.theTokenInput.getValue(),

  title: "Company",

  supportMultiselect: true,

  supportRangesOnly: false,

  key: this.aKeys[0],

  descriptionKey: this.aKeys[1],

  ok: function(oControlEvent) {

  that.aTokens = oControlEvent.getParameter("tokens");

  that.theTokenInput.setTokens(that.aTokens);

  oValueHelpDialog.close();

  },

  cancel: function() {

  sap.m.MessageToast.show("Cancel pressed!");

  oValueHelpDialog.close();

  },

  afterClose: function() {

  oValueHelpDialog.destroy();

  }

  });

  var oColModel = new sap.ui.model.json.JSONModel();

  oColModel.setData({

  cols: [

        {label: "Company Code", template: "CompanyCode"},

        {label: "CompanyCodeName", template: "CompanyCodeName"}

        ]

  });

  oValueHelpDialog.getTable().setModel(oColModel, "columns");

  oValueHelpDialog.getTable().setModel(sap.ui.getCore().getModel("oDataModel1"));

  oValueHelpDialog.getTable().bindRows("/CompanyCodeValuehelp");

  oValueHelpDialog.setRangeKeyFields([{label: "Company Code", key: "Company Code"}, {label : "CompanyCodeName", key:"CompanyCodeName"}]);

  oValueHelpDialog.setTokens(this.aTokens);

  var oFilterBar = new sap.ui.comp.filterbar.FilterBar({

  advancedMode:  true,

  filterBarExpanded: true,

  searchEnabled:true,

  filterGroupItems: [new sap.ui.comp.filterbar.FilterGroupItem({ groupTitle: "foo", groupName: "gn1", name: "n1", label: "Company Code", control: new sap.m.Input()}),

                    new sap.ui.comp.filterbar.FilterGroupItem({ groupTitle: "foo", groupName: "gn1", name: "n2", label: "CompanyCodeName", control: new sap.m.Input()})],

                    search: function(oEvt) {

        var aFilters = [];

      

        var sQuery = oEvt.getSource().getValue();

        if (sQuery && sQuery.length > 0) {

        var filter = new sap.ui.model.Filter("CompanyCode", sap.ui.model.FilterOperator.Contains, sQuery);

        aFilters.push(filter);

        }

        var oColModel = new sap.ui.model.json.JSONModel();

        oColModel.setData({

        cols: [

              {label: "Company Code", template: "CompanyCode"},

           {label: "CompanyCodeName", template: "CompanyCodeName"}

              ]

        });

        oValueHelpDialog.getTable().setModel(oColModel, "columns");

      

        oValueHelpDialog.getTable().setModel(sap.ui.getCore().getModel("oDataModel1"));

      

        oValueHelpDialog.getTable().bindRows("/CompanyCodeValuehelp");

   

        oValueHelpDialog.getTable().filter(aFilters,"Application");

      

                    }

  });


Error


I am getting error in console


Uncaught TypeError: oEvt.getSource(...).getValue is not a function



Regards,

Monika



error1.PNG (30950 B)
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question