cancel
Showing results for 
Search instead for 
Did you mean: 

Uncaught SyntaxError: Unexpected token

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (2)

Answers (2)

saivellanki
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

Hii Sai,

I am new to this technology.

Thanks my issue is resolved.

former_member182372
Active Contributor
0 Kudos

do you have line  number whrerte theat error is?