cancel
Showing results for 
Search instead for 
Did you mean: 

After passing the filter parameter not getting the list

former_member357192
Participant
0 Kudos

Hello,

I can pass the filter parameter but not getting the list . Response is coming from back-end list is empty.

login.Controller.js

S2.Controller.js

Accepted Solutions (1)

Accepted Solutions (1)

former_member357192
Participant
0 Kudos

Hello All,

Here is the correct Answer

what i done. I used a filter values in

xml view

---------------------------------------------------------------------------------------------------------------------------

<List id="list"

          items="{/PO_APPROVALEKKKOset?$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'}"

          mode="{deviceId>/listMode}"

              select="handleSelect"

              growing="true"

              growingScrollToLoad="true">

---------------------------------------------------------------------------------------------------------------------------

On Controller


_pushNewOrders: function () {

        var oView = this.getView();

        var oData = oView.getModel().read("/PO_APPROVALEKKKOset",null,["$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'"], false);

 

     

  },

-------------------------------------------------------------------------------------------------------------------------------

Output:

Thanks

Answers (1)

Answers (1)

Qualiture
Active Contributor
0 Kudos

What is the actual OData request being sent in your browser's network tab? Does it also receive a valid response there?

former_member357192
Participant
0 Kudos

Hello Robin

Thanks for the reply.

Here is the response we r getting .

var list = this.getView().byId("list");
   var binding = list.getBinding("items");
   binding.filter(oFilters);

    },

former_member182372
Active Contributor
0 Kudos

you pass array of strings as 3rd param to red method of odtamodel

["$filter=..."]

it should be array of Filter object

var filters = [

   new sap.ui.model.Filter("MyApprovals", sap.ui.model.FilterOperator.EQ, searchData.myApprovals)

];

Qualiture
Active Contributor
0 Kudos

Ok, but you don;t see any data in your list, right? Where do you bind the results of your ODataModel.read() operation to the list?

former_member357192
Participant
0 Kudos

Yes I am not seen any data on list

here i am binding the result..

------------------------------------------------------------------------------------------------------------

onBeforeRendering: function() {
    alert("123");
    var temp = (sap.ui.getCore().getModel("OdataModel"));
    alert(temp);
   this.getView().setModel(sap.ui.getCore().getModel("i18n"),"i18n");
//   this.getView().setModel(sap.ui.getCore().getModel("deviceId"),"deviceId");
   this.getView().setModel(sap.ui.getCore().getModel("OdataModel"));

    },

// update list binding

        var list = this.getView().byId("list");

        var binding = list.getBinding("items");

        binding.filter(oFilters);

    },

   

    _pushNewOrders: function () {

          var oView = this.getView();

          var oData = oView.getModel().read("/PO_APPROVALEKKKOset", null,[ "$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'"], false);

      },

     

    handleRefresh: function (oEvent) {

        setTimeout(jQuery.proxy(function () {

        this._pushNewOrders();

// Deal with any actual search query

alert("hello");

          var oList = this.getView().byId("list");

          var oSearchField = this.getView().byId("searchField");

          var sQuery = oSearchField.getValue();

          var aFilters = [];

          if (sQuery && sQuery.length) {

           // aFilters.push(new sap.ui.model.Filter("Vbeln", sap.ui.model.FilterOperator.Contains, sQuery));

           aFilters.push(new sap.ui.model.Filter("PO_number", sap.ui.model.FilterOperator.EQ, sQuery));

          }

          oList.getBinding("items").filter(aFilters);

        }, this), 1000);

      },

    ---------------------------------------------------------------------------------

former_member182372
Active Contributor
0 Kudos

what do you see in Network, does URL contain $filter?

former_member182372
Active Contributor
0 Kudos

odatamodel.read 3rd anonymous parmeter is mUrlParams indeed, but why use it for string $filter???

former_member357192
Participant
0 Kudos
former_member182372
Active Contributor
0 Kudos

click on entry and show the right pane

former_member357192
Participant
0 Kudos
Qualiture
Active Contributor
0 Kudos

Again, I repeat my question, where do you store the results from your read() operation? Remember, as the API also points out,


The data will not be stored in the model. The requested data is returned with the response.

What I'm missing is how you handle the 'response' results from the ODataModel.read() success handler?

former_member357192
Participant
0 Kudos

Hello Robin,

Here we are read the response

// update list binding

        var list = this.getView().byId("list");

        var binding = list.getBinding("items");

        binding.filter(oFilters);

    },

   

    _pushNewOrders: function () {

          var oView = this.getView();

          var oData = oView.getModel().read("/PO_APPROVALEKKKOset", null,[ "$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'"], false);

      },

     

    handleRefresh: function (oEvent) {

        setTimeout(jQuery.proxy(function () {

        this._pushNewOrders();

former_member182372
Active Contributor
0 Kudos

ODataModel.read returns not data but

@return {object} an object which has an <code>abort</code> function to abort the current request.

return oRequestHandle;

as suggested, you dont have success handler, you can pass it as 4th parameter


mUrlParams = arguments[2];

bAsync     = arguments[3] !== false; // Defaults to true...

fnSuccess  = arguments[4];

fnError    = arguments[5];

Qualiture
Active Contributor
0 Kudos

I have really no idea what you are doing... The return value for the model.read() operation is


an object which has an abort function to abort the current request


of which you do nothing, but you also do not specify any success/error handler? Have you taken a look at the API for ODataModel.read()?

It clearly says:


Trigger a GET request to the odata service that was specified in the model constructor. The data will not be stored in the model. The requested data is returned with the response.

So again, where do you handle the response? I would have expected something like this:


_pushNewOrders: function () {

  var oView = this.getView();

    oView.getModel().read(

    "/PO_APPROVALEKKKOset",

    null,

    [ "$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'"],

    true,

    function(oData, oResponse) {

    //Here I would have expected something you would do with the received data

    },

    function(oError) {

    }

    );

},

However, somehow I think you could use a better approach than using read():


_pushNewOrders: function () {

  var oList = this.getView().byId("list"),

  sURI = "http://whateveryourserviceurlis/", 

     oModel = new sap.ui.model.odata.ODataModel(sURI,false),

     oBinding = oModel.bindList("PO_APPROVALEKKKOset"),

     oFilter = new sap.ui.model.Filter("Ivappid", sap.ui.model.FilterOperator.Equals, "ZMOB_PO");

  oBinding.filter([

  new sap.ui.model.Filter("Ivappid", sap.ui.model.FilterOperator.Equals, "ZMOB_PO"),

  new sap.ui.model.Filter("Ivmodid", sap.ui.model.FilterOperator.Equals, "PO_APPROVL"),

  new sap.ui.model.Filter("Ivsmodid", sap.ui.model.FilterOperator.Equals, "PO_APPROVL"),

  new sap.ui.model.Filter("Userid", sap.ui.model.FilterOperator.Equals, "VBHANOT"),

  ]);

  oList.setModel(oModel);

},

former_member357192
Participant
0 Kudos

Hello Robin,

check this code  we are doing on login controller. i already mention on 1st post.

Can u clarify me where i am doing wrong?

oModel.read("/PO_APPROVALEKKKOset", null,["$filter=Ivappid eq 'ZMOB_PO' and Ivmodid eq 'PO_APPROVL' and Ivsmodid eq 'PO_APPROVL' and Userid eq 'VBHANOT'"], false,

               

                                function(oData, response)

                                {   

                                    sap.ui.getCore().setModel(oModel,"OdataModel");

                                    var oApp = sap.ui.getCore().byId("App");

                                    oApp.to("SApp");

                                },

                                function(oData, response)

                                {   

                                    jQuery.sap.require("sap.ca.ui.message.message");

                                    sap.ca.ui.message.showMessageBox({

                                        type: sap.ca.ui.message.Type.ERROR,

                                        message: "Service connection couldn't be established",

                                        details: "Error" + " " +

                                                 oData.message+" : "+

                                                 oData.response.statusCode+" : "+

                                                 oData.response.statusText

                                    });

                                    return;

                                });

                               

                    }

Qualiture
Active Contributor
0 Kudos

C'mon, haven't you read my previous post?? I showed you what is wrong with your code!

ok, again, take a look at this:

oModel.read("/PO_APPROVALEKKKOset", /* etc */,         

function(oData, response) {  

    sap.ui.getCore().setModel(oModel,"OdataModel");

    var oApp = sap.ui.getCore().byId("App");

    oApp.to("SApp");

},

Now, tell me, where in your success handler are you using either 'oData' or 'response' ??

Exactly, nowhere.

So the data you retrieved by the 'read()' operation is stored nowhere.