Quantcast
Channel: SCN : All Content - SAPUI5 Developer Center
Viewing all articles
Browse latest Browse all 6178

Unable to do binding context for a sap.m.text

$
0
0

Hi,

I am trying to bind a context for text .But i am not getting expected output.Please check the below code.PFA for the thing i got on alert msg

 

VIEW.JS

-----------------

 

var oData ={"SalesOrderCollection" :  [{name : "RAM",surname : "GOPAL","count":1 },

               {name : "RAJESH",surname : "SRI" ,"count":2}]

 

  };

 

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

 

  oModel.setData(oData);

 

  var list1 = new sap.m.List({

  id : "master1", inset: false,

  itemPress : function(oevent)

  { //var context = oevent.getSource().getBindingContext();

  oController. handleListItemPress(oevent);}

  });

 

  var template = new sap.m.StandardListItem({

  title : "{name}",

  type: sap.m.ListType.Active

  });

 

  list1.setModel(oModel);

 

  list1.bindItems({path : "/SalesOrderCollection",template :template} );

 

  return list1;

 

 

==========================================================================

 

controller.js

-----------------------

 

 

var src = e.getParameter('listItem');

      var obj = src.getBindingContext().getObject();

 

var vbox = new sap.m.VBox();

 

vbox.setBindingContext(obj);

 

  var soid = new sap.m.Text({text: "{name}"});

 

vbox.bindAggregation("items","/SalesOrderCollection" , soid);

 

  alert(JSON.stringify(vbox));

 

======================================================================


Viewing all articles
Browse latest Browse all 6178

Trending Articles



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