Skip to Content

Problem in binding array to table from Component.js

Hi Experts,

I have got my oModel data in an array in the Component.js file. I have returned the array with an entity collection (PFA) and have bind the entity to the table with the code

aData = this.getOwnerComponent().getServiceRequestCollection();

console.log("table array", aData);

var oVizFrame3Model = new sap.ui.model.json.JSONModel(aData);

var oTable = oView.byId("idServiceTable");

oTable.setModel(oVizFrame3Model);

The table is displayed empty and from the console I found that "table array" is undefined. Some quick suggestions as to how to bind the data to the table would be really helpful.

Thanks,

Srinivasan

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Aug 17, 2016 at 01:07 PM

    Hi,

    It would be very helpful if the experts provide some suggestions regarding the same.

    Thanks in advance,

    Srinivasan

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Aug 18, 2016 at 09:43 AM

    Any suggestions from other experts in the forum would be very helpful.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Venkat,


      The altered the code in my Component.js file as you have suggested is put below


      getServiceCollection: function() {

      var oModel = new sap.ui.model.odata.ODataModel("/sap/c4c/odata/v1/c4codata/");

      oModel.read("/ServiceRequestCollection?$filter= CustomerID eq '1001192'", {

      success: function(oData, response) {

      var oResult = new sap.ui.model.json.JSONModel({service:oData.results});

      sap.ui.getCore().setModel(oResult);

      }

      });

      }

      I got this model in my controller using the code sap.ui.getCore().getModel(); and have altered the table code as suggested.

      Still I am facing the same issue. Hope I have not committed a silly mistake.

      Please point it out if you find any.

      Thanks,

      Srinivasan

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.