Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ODATAModel Table binding delay problem

Hi,

I'm using sap.m.Table inside dialog box and binding ODATAModel .

my problem is i'm counting number rows in table (using oTable.getItems().length) and displaying as dialog box titile( ex: Lines(10))

due to more number of records binding is taking time

and count is displaying as "0" .

my code :

onClickPriority: function() {

  var oTablePriority = new sap.m.Table(

  {

  inset: true,

  headerDesign: sap.m.ListHeaderDesign.Standard,

  mode: sap.m.ListMode.None,

  });

  var col = new sap.m.Column(

  {

  });

  oTablePriority.addColumn(col);

  var col1 = new sap.m.Column(

  {

  header: new sap.m.Label({

  text: "Priority"

  })

  });

  oTablePriority.addColumn(col1);

  var col2 = new sap.m.Column(

  {

  header: new sap.m.Label({

  text: "Priority Text"

  })

  });

  oTablePriority.addColumn(col2);

  var dialogTablePriority = new sap.m.Dialog({

    

  content: [oTablePriority],

  beforeOpen: function(){

     var oModelPriority = new sap.ui.model.odata.ODataModel("http://xxxxxxxxxxxxxxxxxx_SRV/");

  oTablePriority.setModel(oModelPriority);

      

  oTablePriority.bindItems("/NotificationPriorityCollection",

  new sap.m.ColumnListItem({

  cells: [new sap.m.RadioButton({

  select: function(evt) {

  var pathno = evt.getSource().getBindingContext().getPath();

  var in1 = pathno.split("/");

  index = in1[1]; // Index

  }

  }),

  new sap.m.Text({

  text: "{Priority}"

  }),

  new sap.m.Text({

  text: "{PriorityText}"

  })]

  }));

  },

  afterOpen : function(){

   dialogTablePriority.setTitle("Priority("+oTablePriority.getItems().length + ")");

  },

  beginButton: new sap.m.Button({

  text: 'Select',

  press: function() {

  var Priority = oTablePriority.getModel().oData[index].Priority;

  var PriorityText = oTablePriority.getModel().oData[index].PriorityText;

  oView.byId('Priorityid').setValue(Priority);

  oView.byId('PriorityTextid').setValue(PriorityText);

  dialogTablePriority.close();

  }

  }),

 

  endButton: new sap.m.Button({

  text: 'Cancel',

  press: function() {

  dialogTablePriority.close();

  }

  }),

  beforeClose: function(){

       var allItems = oTablePriority.getItems();

  var len = allItems.length;

  console.log(len); 

  }

  });

       

  dialogTablePriority.open();

  },

replied

oTablePriority.bindItems("/NotificationPriorityCollection",

........

var binding = oTablePriority.getBinding("items");

if(binding)

{

  binding.attachDataReceived(function () {

  dialogTablePriority.setTitle("Priority("+oTablePriority.getItems().length + ")");

  }, this);

}

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question