cancel
Showing results for 
Search instead for 
Did you mean: 

Binding OData JSON to List

Former Member
0 Kudos

Trying to load my List with OData from a remote URL in JSON format.

Here's what I have in the controller.js onInit method:

//I do have to login to the SAP backend so not sure if this method signature even works.  No exception is being thrown

var oModel = new sap.ui.model.json.JSONModel("url&$format=json", true, "username", "password");

sap.ui.getCore().setModel(oModel);

In my view.js:

var listtemplate = new sap.mObjectListItem({

     title: "{matnum}",

     intro: "{desc}"

});

var list = new sap.m.List("matlist", {

     mode: ....singleselectmaster,

     includeItemInSelection: true,

     ........

});

list.bindAgrregation("Inventory", "results", listtemplte);

JSON data format being returned is:

{

"d" :  {

          "results" : [

                                   { matnum: "data", desc: "data"},

                                   { matnum: "data", desc: "data"},

                                   { matnum: "data", desc: "data"},.............

                                       ............................

                         ]

     }

}

I'm not getting any exception thrown but my list is coming up empty.  What I need is to grab the values of "matnum" on the list.  Any help is greatly appreciated.

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member182862
Active Contributor
0 Kudos

HI Jay

Here is an example.

-D