Sunday, 1 November 2015

how to append the simple json data to the table in sapui5 ?

your xml should conatin the table element


<Table id="table" items="{/items}" mode="Delete" delete="odelete">
<columns>
<Column>
<Text text="First Name" />
</Column>
<Column>
<Text text="Last Name" />
</Column>
</columns>
<items>
<ColumnListItem id="list">
<cells>
<Link id="link" text="{text1}" press="handlePress" />
</cells>
<cells>

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

</Table>




and your controller should load the model data in oninit()




var data = {
"items" : [ {
"text1" : "Rajendra",
"text2" : "Asuri",
"text3" : "M",
"text4" : "001"
}, {
"text1" : "Lakshmana Rao",
"text2" : "Gondi",
"text3" : "M",
"text4" : "002"
}, {
"text1" : "Lakshmi",
"text2" : "Gondi",
"text3" : "F",
"text4" : "003"
} ]

};
var oModel = new sap.ui.model.json.JSONModel(data);
this.getView().byId("table").setModel(oModel);


No comments:

Post a Comment