Skip to Content
0
Oct 22, 2019 at 04:15 AM

Bind a Table using OData model (UI5)

2220 Views Last edit Oct 22, 2019 at 06:47 AM 2 rev

Hello experts i'm very new to sap ui5

i'm trying to bind table in eclipse

i have written the code in XML View is like***

<mvc:View xmlns:mvc="sap.ui.core.mvc" controllerName="abc.controller.POHeader"
displayBlock="true">
<Shell xmlns="sap.m" id="shell">
<App id="app">
<pages>
<Page title="{i18n>title}" id="page">
<content>
<Table id="idTable" items="{/POHeaderSet}" >
<columns>
<Column>
<Label text="a"></Label>
</Column>
<Column>
<Label text="b"></Label>
</Column>
<Column>
<Label text="C"></Label>
</Column>
<Column>
<Label text="d"></Label>
</Column>
<Column>
<Label text="e"></Label>
</Column>
</columns>

<items>
<ColumnListItem>
<cells>
<Text text="{Ebeln}"></Text>
<Text text="{Bukrs}"></Text>
<Input value ="{Ernam}"></Input>
<Text text="{Lifnr}"></Text>
<Text text="{Zterm}"></Text>
</cells>
</ColumnListItem>
</items>
</Table>
</content>
</Page>
</pages>
</App>
</Shell>
</mvc:View>

**and code in controller is like

onInit: function () {
var service = "sap/opu/odata/sap/ZGW_PO_SRV/";

var oModel = new sap.ui.model.odata.ODataModel("service", false);

sap.ui.getCore().setModel(oModel);

var oTable = new sap.ui.getCore().byId("idTable");

oTable.setModel(oModel);

oTable.bindRows("/POHeaderSet");
this.getView().setModel(oModel);
}
});
});

**in manifest.json :

"dataSources": {
"ZGW_PO_SRV": {
"uri": "http://di-fix.***-ext1.com:8005/sap/opu/odata/sap/ZGW_PO_SRV/",
"type": "OData",
"settings": {
"localUri": "localService/metadata.xml",
"odataVersion": "2.0"

}
}
}
},

"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "abc.i18n.i18n"
}
},
"oHeader": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "OneWay",
"defaultCountMode": "Request"
},
"dataSource": "ZGW_PO_SRV",
"preload": true
}
},

but I cant find any values in my output. please help me out