on 01-06-2015 9:07 PM
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));
======================================================================
In the event handler in the controller, you're calling both setBindingContext and bindAggregation on the VBox. The latter (bindAggregation) overrides the effect that setBindingContext would otherwise have on the Text control. Try adding the Text control to the VBox (via addItem) instead of calling bindAggregation.
Also, the VBox needs to have access to the same model as the list. You could do this by setting the model on the view in the first place (instead of the list) and then adding the VBox to the view.
- Max
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.