【问题标题】:SAPUI5 TileContainer nested JSON data bindingSAPUI5 TileContainer 嵌套 JSON 数据绑定
【发布时间】:2017-02-07 01:19:57
【问题描述】:

我想将嵌套在我的模型中的数组“机器”绑定到 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");

在我看来:

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({...})
)};

但是没有任何效果。我试图将它绑定到

  • main>/机器
  • 机器
  • main>机器
  • main>公司/部门/生产/机器
  • main>/company/departments/production/machines/

但没有任何效果。

提前谢谢,我真的卡住了!

【问题讨论】:

    标签: javascript json sapui5


    【解决方案1】:

    编辑: 我做错了。

    这是正确的解决方案:

    您错过了路径中的 / 访问模型中的属性是通过 "modelname">/ 所以 ma​​in>/ 是绑定路径的开始

    main>/company/departments/production/machines
    

    最好的问候

    【讨论】:

    • 这不起作用。我想为阵列机器中的每个对象使用一个磁贴。
    • 更新了我的答案。对不起这个错误。但这肯定会起作用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-23
    • 1970-01-01
    • 1970-01-01
    • 2014-02-09
    • 1970-01-01
    • 2017-03-19
    相关资源
    最近更新 更多