Skip to Content
avatar image
Former Member

Uncaught TypeError: Cannot read property 'layout' of undefined error is coming in value help dialogue while displaying data

hi all,

var layout = new sap.ui.commons.layout.MatrixLayout('layout');

  var rPannel = new sap.ui.commons.Panel('rPannel'); 

  var oTable = new sap.ui.table.DataTable();

     oTable.addColumn( 

          new sap.ui.table.Column({ 

               label: new sap.ui.commons.Label({text: "CompanyCode"}), 

               template: new sap.ui.commons.TextField().bindProperty("value", "CompanyCode")

               

     }));

    

     oTable.addColumn( 

             new sap.ui.table.Column({ 

                  label: new sap.ui.commons.Label({text: "CompanyCodeName"}), 

                  template: new sap.ui.commons.TextField().bindProperty("value", "CompanyCodeName") 

                  

        })); 

    

     var oModel = new sap.ui.model.odata.ODataModel( 

             "services.odata.org/Northwind/Northwind.svc/", 

                                 true, 

                                 "usr", 

                                 "passs");

        oTable.setModel(oModel); 

        oTable.bindRows("/CompanyCodeValuehelp");

        rPannel.addContent(oTable);   

        layout.createRow(rPannel); 

        oValueHelpDialog.addContent(layout);

this is my code, contents from odata are notr getting dispalyed. plz help

thank you.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 27, 2015 at 07:50 AM

    Monika,

    in the constructor of the ODataModel  "class" you can add all information you need.

    So your example should work nearly with following coding:

    // create oDataModel and connect it to service

    var oDataModel = new sap.ui.model.odata.ODataModel(<url to your service>, false, <user>, <password>);

    // Create table

    var oTable = new sap.ui.table.Table();

    // add a column to the table

    oTable.addColumn(new sap.ui.table.Column({ label: new sap.ui.commons.Label({text:"Test Column Header"}), template: new sap.ui.commons.TextField().bindProperty("value", "<value of oData Model part of path bound to rows (see below)>") }) );

    // set oDataModel for table

    oTable.setModel(oDataModel);

    // bind path of oDataModel to table rows

    oTable.bindRows("<path>");

    Building a CRUD Application with SAPUI5 Using Odata Model

    Add comment
    10|10000 characters needed characters exceeded