1
votes

I have 2 models in my application that I bind to sap.ui.core. The following code is from my main view. Which is a split-app.

var checks = {
    items: [
    {
        checklist: "ContainerCheck",
        title:"Scan RFID container",
    }
    // etc...
]}
;

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

In another view I want to bind data to the masterpage

var oItemTemplate = new sap.m.ActionListItem({
    title : "{title}",
    icon : "sap-icon://activity-2",
    activeIcon: "sap-icon://activity-2",
    type : sap.m.ListType.Active,
});

this.oList = new sap.m.List({
    itemPress: [oController.onListSelect, oController]
});

this.oList.bindItems("checks>/items",oItemTemplate);

However I'm not seeing any data in the list. I'm quite sure the sPath is correct checks>/items. Is it not possible to use this sPath because the model is bind to sap.ui.core. Or am I missing something else?

3
your code is wrong, should be sap.ui.getCore().setModel(oModel, "checks");Jasper_07
@Jasper_07 correct I fixed it, but still no data displayedAnonymoose
fyi: you can review bindings and other usefull information with the sapui diagnostics tool. Just press ctrl+shift+alt+s inside your sapui application to open it and use the "Control Tree" to navigate through your controls.masch
@masch thanks, I don't find the model that I bind to sap.ui.core anywhere thoughAnonymoose
Can you create a small jsbin/jsfiddle/codepen for this so we are able to see the problem/failure?masch

3 Answers

2
votes

I'm pretty sure you have to prefix the propertyBinding with the models name:

var oItemTemplate = new sap.m.ActionListItem({
    title : "{checks>title}",
    ...
});

This should work.

0
votes

Try this this.oList.bindItems("{checks>/items}", oItemTemplete); instead of this.oList.bindItems("checks>/items",oItemTemplate);

0
votes

I stumbled about the same problem and after a while I found this comment:

A control can only bind to one model, so if you have a container control with an assigned model, all controls contained in this container can only see the local model of the container and are no longer able to bind to the global model.

I assume that is the problem in your code. At least that's the one in mine :-)