Search code examples
sapui5

Data binding issue with sap.m.SelectDialog


I'm using Sap.m.SelectDialog to display the value request(F4 help in abap).When i do it with JS view all is good,but when do it with XML view by creating the fragment, binding is not happening with the "items" aggregation. please let me know what went wrong.

    var mydata = { data : [
        {
            info: "SAP UI5",
            name: "Sam",
        },
        {
            info: "SAP UI5",
            name: "Ram",
        },
        {
            info: "SAP UI5",
            name: "Prem",
        }
    ]};

Js view logic:

    var oDialog = new sap.m.SelectDialog({
        title: "Select an item",
        items: {
            path:"/data",
            template : new sap.m.StandardListItem({
                title: "{name}"
            })
            }
        })

    oDialog.open();
}

XML fragment :

<SelectDialog xmlns="sap.m"
          id ="id3"
          title="Select a product">


   <items id="ls3"
              path="/data">
              <StandardListItem title="{name}">
              </StandardListItem>
    </items>

.

Reslut of JS view

Result of Xml view


Solution

  • Try XML fragment this way:

        <SelectDialog xmlns="sap.m"
                  id ="id3"
                  items="{/data}"
                  title="Select a product">
    
    
           <items>
                      <StandardListItem title="{name}"/>
            </items>
       </SelectDialog>