Skip to Content

Problem with ODATA Binding to SAP.M.LIST

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jul 21, 2016 at 07:48 AM

    Try

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

    template: oTemplate

    });

    Regards,

    chandan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 21, 2016 at 07:51 AM

    Instead of writing

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


    write like below:

    oModel = new sap.ui.model.json.JSONModel();
    oModel.loadData("proxy/http/xxxxxxxx/sap/opu/odata/SAP/ZCA_ANNOUNCEMENT_TEST_SRV/AnnouncementSet/?$format=json", null,false, "GET", false, false, null)
    
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.