Skip to Content
0
Jun 03, 2020 at 09:32 AM

How to bind oModel Data to table

584 Views

Hello,

I am trying to bind a JsonModel with data from OData to my table in the view, but I can not show the data I want to show in the Listitems.

Hope you can help me.

Thanks and best regards.

Jay

That is my code:

Controller:

var zielTable = this.byId("table_ziele");
                newModel.read("/LAGPSet", {
                    filters: oFilter,
                    success: function (oData, response) {
                        // create JSON model
                        var oODataJSONModel = new sap.ui.model.json.JSONModel();
                        // set the odata JSON as data of JSON model
                        oODataJSONModel.setData(oData);
                        sap.ui.getCore().setModel(oODataJSONModel, "lagpModel");
                        zielTable.setModel(oODataJSONModel, "lagpmodel");
                    },


View:

</Table>
                
                <Table id="table_ziele" width="auto" 
                items="{      path: 'lagpmodel>/results',      sorter: {       path: 'Lgpla',       descending: false      }     }" 
                noDataText="Keine Ziele geladen" growing="true" growingScrollToLoad="true">

                <columns>
                    <Column id="Lagertypen" hAlign="Center">
                        <Text text="Ziellagertyp"/>
                    </Column>
                    <Column id="Lagerplaetze" hAlign="Center">
                        <Text text="Ziellagerplatz"/>
                    </Column>
                </columns>

                <items>
                    <ColumnListItem type="Navigation" press="onPress">
                        <cells>
                            <ObjectIdentifier title="{Lgtyp}"/>
                            <Text text="{Lgpla}"/>
                        </cells>
                    </ColumnListItem>
                </items>
            </Table>


Model:

oData: {…}
      results: (13) […]
                   0: {…}
                   1: {…}
                   2: {…}
                   3: {…}
                   4: {…}
                   5: {…}
                   6: {…}
                   7: {…}
                   8: {…}
                   9: {…}
                   10: {…}
                   11: {…}
                   12: {…}