0
votes

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. But I want the first carId to apppear in the first Item and the second in the second. I tried several syntaxes but they all resulted into an empty List Item.

Thank You!

1

1 Answers

0
votes

You are referencing an absolute path to the title in your template. Change it to a relative path (i.e., relative to the current item in your list) instead:

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