Search code examples
sapui5

Removing model name doesn't display data. Why?


I was able to display my output list if I include OData model name in the path of the "items". But when I removed the OData model, it did not work. Why?

<List items="{myOdata>/SalesOrderSet}">
  <StandardListItem
    title="{myOdata>SalesOrderID}"
    type="Navigation"
    press=".goToDets"
  />
</List>

Solution

  • In general, you should always use this rule when your model is not the default one (default is when the model has no name).

    <List items="{ModelName>/ListOfValues}" id="list0">
        <items>
            <StandardListItem type="Navigation" title="{ModelName>Title}" description="{ModelName>Description}" icon="sap-icon://picture" id="item0" press="GoToDets"/>
        </items>
    </List>
    

    If you're using the default model you should use this kind of template:

    <List items="{/ListOfValues}" id="list0">
        <items>
            <StandardListItem type="Navigation" title="{Title}" description="{Description}" icon="sap-icon://picture" id="item0" press="GoToDets"/>
        </items>
    </List>
    

    Example