SAPUI5 - Table - XML - How to make a SAPUI5 table

2019-07-30 08:48发布

问题:

I want to make a simple table with only XML Views. But I can't find anything that's telling my, how to. How do I tell the table which Model it should use? How do I tell the table which column should be bind with which entry in the model?

I know how to define the columns. My data is stored (for the moment) in a .json file. Later I want to use a OData service.

Here is some code:

<Table>
    <items></items><!-- sap.m.ListItemBase -->
    <columns>
        <Column>
            <Label text="Date"/>
        </Column>
        <Column>
            <Label text="Article"/>
        </Column>
    </columns><!-- sap.m.Column -->
</Table>

Is there a items attribute in the Table tag where I bind the Model to the data?

I think in the <items>tag there I must define a ListItemBase but I cann't see how to bind Model Entry and Column.

<items>
    <ListItemBase
        id="id"
        busy="false"
        busyIndicatorDelay="1000"
        visible="true"
        fieldGroupIds="[]"
        type="Inactive"
        visible="true"
        unread="false"
        selected="false">
    </ListItemBase>
</items><!-- sap.m.ListItemBase -->

回答1:

Some more search in the internet solved my question:

Bind the data to the table via <Table items="{/model}">.

To tell the table which entries in your model to use, use:

<items>
    <ColumnListItem>
        <cells>
            <Label text="{text1}" />   
            <Label text="{text2}" />   
        </cells>
    </ColumnListItem>
</items>

Or you use a <ObjectIdentifier>.

But why is the WebIDE telling me, to use <ListItemBase>but not <ColumnListItem>. Is it just a bug in the WebIDE or do I get something wrong here?