retrieve bindingcontext from list and standardlistitem
I think this is a silly question but since I am a newbie and i am trying to learn sapui5 kindly guide me .I am using a sap.m.List and sap.m.StandardlistItem as a template to the list.
Now sap.m.list has some events like select , selectionchange etc and whereas sap.m.standardlistitem has some events like tap, press etc.
Now my question is
1. To which control should i set my model to (is it list or standardlistitem)
2. In Which event should i get the bindingcontext ? is it inside the list events or standardlistitem events?
3. I have seen to retrieve a bindingcontext we have 2 ways
I am confused which one to use to retrieve the bindingcontext . It has become like a trial and error for me, if one doesn work i choose another one.
So kindly guide me what approach should one take to retieve the bindingcontext
indrajith patel replied
1. You have to set a model to the control which has an aggregation associated with it. So in your case it should be sap.m.List
2. You can use either of the events to get the binding context (i.e you can get the bindingcontext from list events as well as standardlistitem events)
3.1 .Get BindingContext from list events
for example in select event you have to use oevent.getParameter("listItem").getBindingContext()
You can refer the example provided by sai for getting the bindingcontext from list events
3.2 Get BindingContext from StandardListItem events
For example in press event you have to use oevent.getSource().getBindingContext()
here is an example.