Skip to Content
author's profile photo Former Member
Former Member

Reg:Unable to display data in List

Hi,

I am creating an MVC mobile application using SAPUI5.I have used JSON model to populate the data.I have done the relevant data binding to UI but the data is not being displayed.

Please find the code I have used to display the data in the List.. All are mobile components(sap.m).

createContent : function(oController) {

var oPage = new sap.m.Page({

title:"Home",

});

var oList = new sap.m.List({headerText: "Countries", items:

[

new sap.m.ObjectListItem("countries", {attachDetailPress : oController.listItemTriggered,

bindContext : "{/countries}"}),

]});

oPage.addContent(oList);

return oPage;

}

This is the MODEL JSON structure,

"countries" : [ {

"name" : "Greece",

"short" : "GR",

"detailInfo": {

"capital": "Athens",

"population": 10787690,

"area": 131990,

"currency": "Euro",

"flagUrl": "http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Flag_of_Greece.svg/200px-Flag_of_Greece.svg.png"

}

Please help me in this.

Thanks,

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 08, 2014 at 12:06 PM

    I have sorted it out,Please find the working code.

    this.countryList = new sap.m.List({

    headerText : "Countries",

    showNoData : false

    });

    this.countryList.bindAggregation("items", {

    path : "/countries",

    sorter : new sap.ui.model.Sorter("name", false),

    template : new sap.m.StandardListItem({

    title : "{name}",

    type : sap.m.ListType.Navigation,

    customData : [

    new sap.ui.core.CustomData({

    key: "name",

    value: "{name}"

    }),

    ],

    tap : [ oController.listItemTriggered, oController ]

    })

    });

    Thanks..

    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.