Skip to Content
May 27, 2016 at 09:44 AM

local json file vs data maintained in controller


Hi all

This is my code in controller init method

mycontroller = this

var data =



"Updates":[{ "Test": "abc"}, {"Test": "bca"},{"Test": "dbd"}] },


"Updates":[{ "Test": "abc"}, {"Test": "bca"},{"Test": "dbd"}] },


"Updates":[{ "Test": "abc"}, {"Test": "bca"},{"Test": "dbd"}] }


var oModel = new sap.ui.model.json.JSONModel();


//set this model to list control having custom list as aggregation



var ListItems = P1Notificationcontroller.P1ticket.getItems();

var ListLength = ListItems.length;

for(var i=0; i<ListLength; i++){

var control = "status_vbox-list1-"+i;

sap.ui.getCore().byId(control).bindAggregation("items",{path:"Updates",template:new sap.m.Text('',{text:'{Update}'})});


view declaration create content

oController.List1 = new sap.m.List("list1",{headerDesign : sap.m.ListHeaderDesign.Standard});

oController.List1_template = new sap.m.CustomListItem("McustomlistItem",{content : [

new sap.m.VBox('',{items:


new sap.m.Text('',{text:"{No}"})

new sap.m.VBox('status_vbox',{items:[]})



The above code in view and controllers init method works perfectly fine the items in custom list vbox are aggregated from update array in data

when the same data when maintained in local json file &

by using this line of code

var jsonmodel = new sap.ui.model.json.JSONModel("mockData/local.json");


the loop for vbox is failing because we are not able to loop the object .

when i console.log of both models odata attribute of one model is showing as Array and other as object , because of object the loop is not happening

how can we maintain the same data in local json file to loop the updates attribute to the vbox in custom list item as above.