Skip to Content
0

SAP UI5 data binding to list in master page not working

Nov 16, 2017 at 05:37 AM

31

avatar image
Former Member

Hi experts,

I have create a master and detail page in my application.

When I bind the data from odata to the list of master page it works fine but when I bind the data from local json file it does not work.

{
	"Item": [{
		"Emp_ID": "H247070",
		"Emp_Name": "Sidhant Acharya"
	}, {
		"Emp_ID": "H247071",
		"Emp_Name": "Json Smith"
	}, {
		"Emp_ID": "H247072",
		"Emp_Name": "John Canedy"
	}, {
		"Emp_ID": "H247073",
		"Emp_Name": "Barak Obama"
	}, {
		"Emp_ID": "H247074",
		"Emp_Name": "Ricky Martin"
	}, {
		"Emp_ID": "H247075",
		"Emp_Name": "Priya Sharma"
	}]
}

//List to display the list in page of master view
		olistCatgery =  new sap.m.List("Id", {
			includeItemInSelection : true,			
			inset : true,
			growing:true,			
			itemPress : function(oEvent) {  //Item Press Event
				 oController.onSelect(oEvent); }
		});
		
		//Search bar
		var oBar = new sap.m.Bar('searchBar',{
			contentMiddle:[
			               new sap.m.SearchField('search',{
			            	   id:'searchField',
			            	   tooltip: 'Do some search...',
			            	   placeholder: 'Search',
			            	   showRefreshButton: true,
			            	   refreshButtonTooltip: 'Refresh',
			            	   showNavButton: true,
			            	   liveChange:oController.onSearch})
			               ]})
		
		//Template in the list to display the items
		oTemplate = new sap.m.StandardListItem("idItems", {
			   title : "{Emp_ID}",
			   description: "{Emp_Name}",
				   type : sap.m.ListType.Navigation,
					  });
		//Bind the data to the template
		olistCatgery.bindAggregation( "items", { 
			 path : "/item",
			 template: oTemplate
			 
		});

login-page.png (45.3 kB)
model.png (11.1 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Irfan Gokak Nov 16, 2017 at 11:35 AM
0

Hi,

Change code as below.

//Bind the data to the template
		olistCatgery.bindAggregation( "items", { 
			 path : "/Item",
			 template: oTemplate
			 
		});

// In controller use
this.getView().setModel(oModel);
Share
10 |10000 characters needed characters left characters exceeded