Skip to Content
avatar image
Former Member

Uncaught SyntaxError: Unexpected token

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Oct 29, 2015 at 03:51 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 28, 2015 at 07:21 PM

    do you have line  number whrerte theat error is?

    Add comment
    10|10000 characters needed characters exceeded