Skip to Content

oData Binding to Table

Hi All,

I have XML view :

<mvc:View controllerName="newApp.controller.App" displayBlock="true"
  xmlns:mvc="sap.ui.core.mvc" xmlns:sap.ui.core="sap.ui.core" xmlns="sap.m">


  <App>
  <pages>
  <Page title="Latihan Table" icon="sap-icon://hello-world">
  <content>
  <Panel>
  <content>
  <Panel headerText="Consume Data From HANA View">

<Table id="table1" firstVisibleRow="5" visibleRowCount="10" xmlns="sap.ui.table">

  </Table>

</Panel>
  </content>
  </Panel>
  </content>
  </Page>
  </pages>
  </App>
</mvc:View>

and Controller that will load oData and bind it to my table :

sap.ui.define([
   "sap/ui/core/mvc/Controller",
   "sap/ui/model/json/JSONModel"
], function (Controller, JSONModel) {
   "use strict";
   return Controller.extend("newApp.controller.App", {


       onInit : function (){
      var url = "http://192.168.1.27:8000/latihan_consume_view/xsdata.xsodata/";
      var oData = new sap.ui.model.odata.ODataModel(url);
    //load data into table
      var atable = this.getView().byId("table1");
      var col1 = new sap.ui.table.Column({
      label : new sap.ui.commons.Label({text : "ID"})
      });
      var col2 = new sap.ui.table.Column({
      label : new sap.ui.commons.Label({text : "NAMA"})
      });      
      atable.addColumn(col1);atable.addColumn(col2);
      atable.setModel(oData);
      atable.bindRows({
      path: "/HANAVIEW",
      parameters : {
      select : "ID,NAMA"
      }
      });
   });
});

Can't get this thing work.. Data can't loaded to my table..

Do guys have any idea?

Thank you

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Dec 15, 2015 at 06:58 PM

    you have to define a template in column

    like

    new sap.ui.table.Column({

    ...

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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 15, 2015 at 10:24 AM

    var oData = new sap.ui.model.odata.ODataModel(url)

    oData.attachMetadataFailed(function(){

    alert('fail');

    }).attachRequestFailed(function(){alert('Fail');});

    Regards,

    Karthik A

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.