Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3510

Re: Unable to create dynamic table in sap ui5

$
0
0

Hi Sergio..

Thanks for the reply..

The problem was not in the data coming in success callback function. Actually there were some issues in the the data binding.I create two models and set column and row data in those models respectively.

Now I am able to display the column but the rows are not getting populated. Please suggest a solution for it.

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

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

  var submitButton = new sap.ui.commons.Button({

  id : "btnSubmit",

  text : "Submit",

  press : buttonPressed

  });

  function buttonPressed() {

  var data = null;

  columnData = null;

  var url1 = path to service;

 

 

  debugger;

  jQuery.ajax({

  url : url1,

  type : "GET",

  contentType : "application/json;charset=utf-8",

  dataType : "json",

 

 

  success : function(data) {

oModel.setData({

     columns: data

  });

 

},

     error : function(e) {

      console.log(e);

     }

 

 

  });

var data = null;

  var url2 = path to service;

 

 

  debugger;

  jQuery.ajax({

  url : url2,

  type : "GET",

  contentType : "application/json;charset=utf-8",

  

  dataType : "json",

 

 

  success : function(data) {

 

  oModel1.setData({

    rows: data

  });

 

},

     error : function(e) {

      console.log(e);

     }

 

 

  });

 

 

  return;

 

  };

sap.ui.getCore().setModel(oModel,"model");

  sap.ui.getCore().setModel(oModel1,"model1");

        var oTable = new sap.ui.table.Table({

     visibleRowCount: 20

  });

     

  //oTable.setModel(oModel);

     

  oTable.bindColumns("model>/columns", function(sId, oContext) {

     var sColumnId = oContext.getObject().COLUMN_NAME;

     console.log(sColumnId);

     return new sap.ui.table.Column({

    

      id : sColumnId,

         label: sColumnId,

         template: sColumnId,

       

         sortProperty: sColumnId,

         filterProperty: sColumnId

     });

  });

 

  //oTable.setModel(oModel1);

  oTable.bindRows("model1>/");Tool.PNG

 

Thanks,

Shama


Viewing all articles
Browse latest Browse all 3510

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>