on 09-08-2014 9:20 AM
Hello Experts,
I have a dropdown which is bound to a list and the data is retrieved from a JSON model. Now what I want to achieve is on selection of value in the dropdown , I need to retrieve corresponding 4 values from the JSON list. Below is the code snippet for beinding :
var oListTemp = new sap.ui.core.ListItem();
oListTemp.bindProperty("text", "projectName");
oListTemp.bindProperty("key", "projNumber");
oProjectsDropDown.bindItems("/projData", oListTemp);
Apart from just projectName and projNumber, I have 2 other properties whose values I need.
oProjectsDropDown.getValue(),oProjectsDropDown.getSelectedKey() - I am able to retrieve the selected value and key , but how do I retrieve other values as well depending on the corresponding selection.
Thanks & Regards,
Archana
You can get to the whole object within the binding context. I've put together an example for you here: http://jsbin.com/hogizu/2/edit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
There are many ways to do this.
On selection of item :
you can get the binding context of the selected item and use that context to read the desired property from the model.
select : function(oEvent)
{
var bindingContext = oEvent.getSource().getBindingContext();
var myProperty = oModel.getProperty("your property",bindingContext );
}
And if you are getting that selected item on some other control's event then
var bindingContext = selectedItem.getBindingContext();
var myProperty = oModel.getProperty("your property",bindingContext );
Hope it will help you a bit.
Regards,
KK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can someone help on this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Archana,
Another way is to extend the ListItem control:
sap.ui.core.ListItem.extend("customListItem", {
metadata : {
properties : {
"property1" : "string",
"property2" : "string",
}
}
});
Then you can bind all properties on customListItem.
Here an example:
http://jsbin.com/gufatifeqali/1/edit?html,output
Regards,
Francesco
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
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.