cancel
Showing results for 
Search instead for 
Did you mean: 

Reg:Unable to display data in List

former_member222013
Participant
0 Kudos

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..."

        }

Please help me in this.

Thanks,

Accepted Solutions (1)

Accepted Solutions (1)

former_member222013
Participant
0 Kudos

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..

Answers (0)