2

I have a problem with multimodel binding.

In init function of controller i set JSON model in ui.core

var oModel = new sap.ui.model.json.JSONModel(data1);
sap.ui.getCore().setModel(oModel, "model1");

in View I have a template of ColumnListItem and I bind it in a table

    var template = new sap.m.ColumnListItem({
          id: "first_template",
          type: "Navigation",
          type : sap.m.ListType.Active,
          visible: true,
          selected: true,
          cells: [ new sap.m.Label({
                    text: "{name}"
                    })
          ],
          press: [oController.pressListMethod]


  });

   oTable.bindItems("model1>/events", template, null, null);
   oPage.addContent(oTable);

With simple Model it work's rigth but in Multimodel table only gets the number of items but not the properties of the model. Any solution ?

1 Answer 1

2

You need to use the model name in the template, too:

var template = new sap.m.ColumnListItem({
  id: "first_template",
  type: "Navigation",
  type : sap.m.ListType.Active,
  visible: true,
  selected: true,
  cells: [ 
    new sap.m.Label({
      text: "{model1>name}" // No leading "/" here since the binding is relative to the aggregation binding below
    })
  ],
  press: oController.pressListMethod
});

oTable.bindItems("model1>/events", template);
oPage.addContent(oTable);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.