Skip to Content
0
Jul 20, 2016 at 09:44 PM

Problem with ODATA Binding to SAP.M.LIST

255 Views

Hello All,

I am new to UI5 and I need to display a list(Master and Details) in the page. I have created new ODATA Model and When I am trying to Bind the model to sap.m.list I am not succesful. I browsed SDN and tried so may ways but no luck. Can some one help me in this.

I have referred the post which suits my case but no luck,

{

"d" : {

"results" : [

{

"__metadata" : {

"id" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(1)",

"uri" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(1)",

"type" : "ZCA_ANNOUNCEMENT_TEST_SRV.Announcement"

},

"Id" : 1,

"Header" : "Header1",

"Details" : "Announcement Text",

"CreatedBy" : "KATKOORR",

"StopFlag" : "T",

"ChangedBy" : "AENAM"

},

{

"__metadata" : {

"id" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(2)",

"uri" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(2)",

"type" : "ZCA_ANNOUNCEMENT_TEST_SRV.Announcement"

},

"Id" : 2,

"Header" : "Header2",

"Details" : "Announcement Test2",

"CreatedBy" : "AMIREDDJ",

"StopFlag" : "F",

"ChangedBy" : "DHARMANA"

},

{

"__metadata" : {

"id" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(3)",

"uri" : "http://xxxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet(3)",

"type" : "ZCA_ANNOUNCEMENT_TEST_SRV.Announcement"

},

"Id" : 3,

"Header" : "Header3",

"Details" : "Announcement Test3",

"CreatedBy" : "ANGARK",

"StopFlag" : "F",

"ChangedBy" : "KATKOORR"

}

]

}

}

Coding:

olistcatgery = new sap.m.List("idHdr",{

inset : false,

itemPress : function(oEvent) { //Item Press Event

oController.onSelect(oEvent); }

});

oTemplate = new sap.m.StandardListItem("idItems", {title : "{ChangedBy}",

description: "{Header}",

icon : "sap-icon://employee",

type : sap.m.ListType.Navigation,

});

oModel = new sap.ui.model.json.JSONModel("proxy/http/xxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet/?$format=json");

olistcatgery.setModel(oModel);

olistcatgery.bindAggregation( "items", { path : "/",

template: oTemplate

});

Regards,

Rajesh K