Steinroe Steinroe - 2 months ago 42
JSON Question

SAPUI5 TileContainer nested JSON data binding

I want to bind the array "machines" which is nested in my model to a SAPUI5 sap.m.TileContainer.



var data_main = {
"name":"1",
"company":{
"money":100000,
"name":"2",
"departments":{
"marketing":{
"marketingActivities":[

],
"marketingModifier":0,
"numberOfEmployees":1
},
"production":{
"output":14281.287062979532,
"outputCoefficientOfEmployees":10,
"machines":[
{
"priceForNextUpdate":0,
"effectOnOutput":200,
"level":1,
"price":0,
"name":"lauterTub",
"id":1,
"value":2000,
"costPerRound":100
},
{
"priceForNextUpdate":0,
"effectOnOutput":500,
"level":1,
"price":0,
"name":"fermantingVat",
"id":2,
"value":5000,
"costPerRound":200
},
{
"priceForNextUpdate":0,
"level":0,
"price":0,
"effectOnCapacity":0,
"name":"storage",
"id":3,
"value":0,
"costPerRound":0
},
{
"priceForNextUpdate":0,
"effectOnQuality":0,
"level":0,
"price":0,
"name":"beerFilter",
"id":4,
"value":0,
"costPerRound":0
},
{
"priceForNextUpdate":0,
"effectOnOutput":300,
"level":1,
"price":0,
"name":"brewingCopper",
"id":5,
"value":3000,
"costPerRound":200
},
{
"priceForNextUpdate":0,
"effectOnOutput":200,
"level":1,
"price":0,
"name":"mashTub",
"id":6,
"value":2000,
"costPerRound":50
},
{
"priceForNextUpdate":0,
"effectOnQuality":0,
"level":0,
"price":0,
"name":"whirlpool",
"id":7,
"value":0,
"costPerRound":0
},
{
"priceForNextUpdate":0,
"effectOnOutput":100,
"level":1,
"price":0,
"name":"maltMill",
"id":8,
"value":1000,
"costPerRound":50
}
],
"numberOfEmployees":2,
"quality":0,
"capacity":0
},
"procurement":{
"numberOfEmployees":1
},
"sales":{
"numberOfEmployees":2
}
},
"numberOfEmployees":6
},
"publicData":{
"markt":"Beispieleigenschaft des Marktes"
}
}
var model_main = new sap.ui.model.json.JSONModel(data_main);
sap.ui.getCore().setModel(model_main, "main");





In my view:



new sap.m.TileContainer("tilecontainer_production", {
width: "55em",
height: "35em",
editable: true,
allowAdd: true,
tiles: {
path: "main>/company/departments/production/machines",
template: new sap.m.CustomTile({...})
)};





But nothing works. I tried to bind it to


  • main>/machines

  • machines

  • main>machines

  • main>company/departments/production/machines

  • main>/company/departments/production/machines/



but nothing works.

Thanks in advance, I am really stuck!

Answer

Edit: I've done a mistake.

This is the correct solution:

You missed the / within the path Accessing the property within the model is done with "modelname">/ so main>/ is the beginning of the binding path

main>/company/departments/production/machines

Best regards