Hello SAPUI5 Gurus,
I am new to SAPUI5, when I am trying to work on sap.m.Table, I am getting above mentioned error.
Please help me out to resolve the error. below I am pasting my code snippet.
my Controller:
sap.ui.controller("table1.myView", {
onInit: function() {
var oModel1 = new sap.ui.model.json.JSONModel("model/details.json");
this.getView().setModel(oModel1);
this.getView().byId("idfn").bindProperty("text","/details1/0/firstname");
this.getView().byId("idln").bindProperty("text","/details1/0/lastname");
this.getView().byId("idcity").bindProperty("text","/details1/0/city");
this.getView().byId("idfn1").bindProperty("text","/details1/1/firstname");
this.getView().byId("idln1").bindProperty("text","/details1/1/lastname");
this.getView().byId("idcity1").bindProperty("text","/details1/1/c");
this.getView().byId("idfn2").bindProperty("text","/details1/2/firstname");
this.getView().byId("idln2").bindProperty("text","/details1/2/lastname");
this.getView().byId("idcity2").bindProperty("text","/details1/2/city");
},
onGetdata : function()
{
var otable = this.getView().byId("idTable");
var oitems=otable.getSelectedItem();
alert(oitems);
var ovalue = items.getBindingContext();
alert(ovalue);
alert(ovalue.getProperty("firstname"));
}
});
my View:
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="table1.myView" xmlns:html="http://www.w3.org/1999/xhtml">
<Page title="Table Example">
<Table id="idTable" BackgroundDesign="Solid" mode="SingleSelectLeft">
<columns>
<Column>
<Label value="First Name"/>
</Column>
<Column>
<Label value="Last Name"/>
</Column>
<Column>
<Label value="City"/>
</Column>
</columns>
<items>
<ColumnListItem>
<cells>
<Text id= "idfn"/>
<Text id= "idln"/>
<Text id= "idcity"/>
</cells>
</ColumnListItem>
<ColumnListItem>
<cells>
<Text id= "idfn1"/>
<Text id= "idln1"/>
<Text id= "idcity1"/>
</cells>
</ColumnListItem>
<ColumnListItem>
<cells>
<Text id= "idfn2"/>
<Text id= "idln2"/>
<Text id= "idcity2"/>
</cells>
</ColumnListItem>
</items>
</Table>
<Button text="GetData" press="onGetdata"/>
<Button text="Update" press="onUpdate"/>
<Button text="Delete" press="onDelete"/>
</Page>
</core:View>
my JSON file:
{
"details1" : [
{
"firstname": "Raju",
"lastname": "Thammineni",
"city": "Hyderabad"
},
{
"firstname": "Sai",
"lastname": "Gowtham",
"city": "Hyderabad2"
},
{
"firstname": "Shiva",
"lastname": "mandla",
"city": "Hyderabad3"
}
]
}