on 10-28-2015 6:19 PM
Hii ,
I am trying to bind my table with odata service in index.html. I am using the following code:
var tableo = new sap.ui.table.Table({
title : "Indian Cricket Team",
visibleRowCount : 5,
selectionMode : sap.ui.table.SelectionMode.Single
});
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Sr No."}),
template: new sap.ui.commons.TextView().bindProperty("value", "Srno"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Player"}),
template: new sap.ui.commons.TextView().bindProperty("value", "Player"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Age"}),
template: new sap.ui.commons.TextView().bindProperty("value", "Age"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Country"}),
template: new sap.ui.commons.TextView().bindProperty("value", "Country"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Email"}),
template: new sap.ui.commons.TextView().bindProperty("value", "Email"),
width: "200px"
}));
var odatao = new sap.ui.model.odata.ODataModel({
'/sap/opu/odata/sap/ZODATA_TEAM_SRV',
false,
"userid",
"password"
});
tableo.setModel(odatao);
tableo.bindRows("/zteam_enity_typeSet");
tableo.placeAt("content");
But when i rumn this in chrome Browser It is showing the Uncaught SyntaxError: Unexpected token . And odata service is working properly in gateway client.
Please Help.
Hi Mayank,
Two things you have to correct in your code.
1. When you are defining ODataModel, no need of {}, it should be
var odatao = new sap.ui.model.odata.ODataModel(
'/sap/opu/odata/sap/ZODATA_TEAM_SRV',
false,
"userid",
"password"
);
2. You are using Text View as the template for table values. Text View doesn't have 'value' property, instead you have to use 'text' property. If you want 'value' then you have to change your control to sap.ui.commons.TextField.
All together, your working code should be like this -
var tableo = new sap.ui.table.Table({
title : "Indian Cricket Team",
visibleRowCount : 5,
selectionMode : sap.ui.table.SelectionMode.Single
});
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Sr No."}),
template: new sap.ui.commons.TextView().bindProperty("text", "Srno"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Player"}),
template: new sap.ui.commons.TextView().bindProperty("text", "Player"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Age"}),
template: new sap.ui.commons.TextView().bindProperty("text", "Age"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Country"}),
template: new sap.ui.commons.TextView().bindProperty("text", "Country"),
width: "200px"
}));
tableo.addColumn(new sap.ui.table.Column({
label: new sap.ui.commons.Label({text: "Email"}),
template: new sap.ui.commons.TextView().bindProperty("text", "Email"),
width: "200px"
}));
var odatao = new sap.ui.model.odata.ODataModel(
'/sap/opu/odata/sap/ZODATA_TEAM_SRV',
false,
"userid",
"password"
);
tableo.setModel(odatao);
tableo.bindRows("/zteam_enity_typeSet");
tableo.placeAt("content");
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
do you have line number whrerte theat error is?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.