Controller Binding

view.xml : 

<content>

<Table id="tableId"  >
<columns>
<Column>
<Text text="Name" />
</Column>
<Column>
<Text text="Age"/>
</Column>
<Column>
<Text text="Gender"/>
</Column>
<Column>
<Text text="Address"/>
</Column>

</columns>
</Table>


</content>



data.json:


{
"data":[
{
"Name":"Tushar",
"Age":"18",
"Gender":"male",
"Address":"kharghar"
},
{
"Name":"Digvijay",
"Age":"21",
"Gender":"male",
"Address":"Ghansoli"

},
{
"Name":"Richa",
"Age":"05",
"Gender":"Female",
"Address":"Ghatkopar"

},
{
"Name":"Aasawari",
"Age":"29",
"Gender":"female",
"Address":"vikroli"

}
]

}



controller.js :



onInit: function() {
var that=this;
var json
var a=that.byId("tableId");
json=new sap.ui.model.json.JSONModel("model/data.json");
a.setModel(json);
a.bindItems("/data", new sap.m.ColumnListItem({
        cells : [
                 new sap.m.Text({
                text : "{Name}",
                 }), new sap.m.Text({
                text: "{Age}"
                 }), new sap.m.Text({
                text: "{Gender}"
                 }),
                 new sap.m.Text({
                text : "{Address}",
                 }),
             ]

}));

  },

Post a Comment

Previous Post Next Post