简体   繁体   English

SAPUI5列表数据绑定数组

[英]SAPUI5 List Data Binding Array

I want to bind a list and its content to a model. 我想将列表及其内容绑定到模型。

var oT =  new sap.m.StandardListItem({
        title: "{carDataModel>/cars/1/carId}",
    });

    var oList = new sap.m.List("carList", {
      });
    oList.bindItems('carDataModel>/cars', oT);

I attached the following model to the view: 我将以下模型附加到视图:

 { "cars":[ { "carId":"e7f2b1519ed5", "carName":"one", }, { "carId":"f3ab598a85e0", "carName":"two", } ] } 

This way I get a list consisting of two List Items and by changing the 1 to a 0 I can switch between the values. 这样,我得到了一个包含两个列表项的列表,并且通过将1更改为0,可以在两个值之间切换。 But I want the first carId to apppear in the first Item and the second in the second. 但我希望第一个carId出现在第一个项目中,第二个出现在第二个项目中。 I tried several syntaxes but they all resulted into an empty List Item. 我尝试了几种语法,但是它们都导致一个空的列表项。

Thank You! 谢谢!

You are referencing an absolute path to the title in your template. 您引用模板中标题的绝对路径。 Change it to a relative path (ie, relative to the current item in your list) instead: 将其更改为相对路径(即,相对于列表中当前项目的相对路径):

var oT =  new sap.m.StandardListItem({
    title: "{carDataModel>carId}",
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM