Question

I want set the content of a list into a popover. The result is this: enter image description here

There are two list by different data binding. The 2nd work and the 1st not work...

This is the xml of the popover

<Popover
    showHeader="false"
    contentWidth="320px"
    contentHeight="500px"
    placement="Bottom" >

    <List 
        items="{menuPath>/pathlist}"> 
         <StandardListItem title="{level}" />    
    </List>


    <List 
        items="{/nodes}">  
         <StandardListItem
          title="{text}"
          type="Navigation"
          tap="doNavOnSelect" >       
        </StandardListItem> 
    </List>


  </Popover>

The 1st data-binding (not-work) is this:

var aPath=new Array();
        obj=new Object(); obj.level='lev1'; aPath.push(obj); 
        obj=new Object(); obj.level='lev2'; aPath.push(obj); 
        obj=new Object(); obj.level='lev3'; aPath.push(obj); 

        var oModel = new sap.ui.model.json.JSONModel();
        //oModel.setData({pathlist:aPath}, true);
        oModel.setData({pathlist:[{level:'uno'},{level:'due'},{level:'tre'}]}, true);
        sap.ui.getCore().setModel(oModel, "menuPath");

and the 2nd data-binding (work) is this:

this.getView().setModel(new sap.ui.model.json.JSONModel("apps/appIntra/master/GEN_intra_Master.json"));

and the json file is this:

{
    "nodes" : [ 
        {
            "id" : "help",
            "text" : "Help"
        }, 
        {
            "id" : "intra_acquisti",
            "text" : "ACQUISTI"
        },
        {
            "id" : "intra_cessioni",
            "text" : "CESSIONI"
        }
    ]       
}
Was it helpful?

Solution

Instead of

<StandardListItem title="{level}" />

use

<StandardListItem title="{menuPath>level}" />

If you use named models, always remember to include them in all the bindings where necessary :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top