Hello everyone, I'm new to the world of sap UI5 and I'm trying to find examples/code snippets to point me in the right direction for a data element I'm creating. Essentially I'm attempting to create a growing list that will hold basic text data the user inputs. I would like to utilize a JSON object to hold/append the inputs and display them in the growing list. In order to get comfortable with the basics of Aggregation Binding I'm attempting to follow the example here.
Here's what I have.
App.controller.js
onInit: function() { var oCompanyList = this.getView().byId("companyList"); oCompanyList.bindAggregation("content", "/companies", this.createContent.bind(this)); }, createContent: function (sId, oContext) { var oUIControl = null; // Define the description var sDescription = oContext.getProperty("name") + " (" + oContext.getProperty("county") + ")"; oUIControl = new sap.m.ObjectListItem(sId, { title : sDescription}); return oUIControl; }
Content.json
{ companies : [ { name : "Acme Inc.", city: "Belmont", state: "NH", county: "Belknap", revenue : 123214125.34 },{ name : "Beam Hdg.", city: "Hancock", state: "NH", county: "Belknap" revenue : 3235235235.23 },{ name : "Carot Ltd.", city: "Cheshire", state: "NH", county: "Sullivan", revenue : "Not Disclosed" }] }
App.view.xml
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" controllerName="aggregation-binding.webapp" xmlns:html="http://www.w3.org/1999/xhtml"> <Page title="Title"> <content> <List id="companyList" items="{/companies}" growing="true" > </List> </content> </Page></core:View>
I'll leave out index.html since I'm sure the error does not stem from there. When I attempt to run this I receive the following error "Error: Missing template or factory function for aggregation items of Element sap.m.List#idwebapp1--companyList !"
I've attempted to troubleshoot it for a while now and I'm wondering if perhaps there is a easier way to get comfortable with these bindings or if there is something obvious I'm missing!
Thanks in advance!