Skip to Content

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

retrieve bindingcontext from list and standardlistitem

Hi everyone,

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

a)  oEvent.getSource().getBindingContext()

b) oEvent.getParameter("listItem").getBindingContext()

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

Thanks &regards

Lahari

Tags:
Former Member
Former Member replied

Hi lahari,

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()

here is the api doc JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.m.ListBase

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.


JS Bin - Collaborative JavaScript Debugging



0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question