Skip to Content
0
Apr 23, 2014 at 11:08 PM

Accessing controls on a custom list item

1027 Views

All,

I have ready many posts on here about similar topics but cannot get any of the solutions to work for me so I thought I would throw my issue on here.

I have the following structure:

sap.m.List

sap.m.CustomListItem

sap.m.ObjectHeader

sap.m.FlexBox

sap.m.Input

sap.m.Button

sap.m.CustomListItem

sap.m.ObjectHeader

sap.m.FlexBox

sap.m.Input

sap.m.Button

... and so on.

I am able to bind data to the sap.m.List and display the info with no issues. I am trying to accomplish a few things:

1. When I press sap.m.Button I would like to get the current value of sap.m.Input, I am able to do this (sort of) by traversing through the sap.m.List.getSelectedItems() etc all the way down to sap.m.input -- the problem arises when, for example, the 2nd item in the list is selected and I press the first button, the value that is returned for sap.m.Input is the value from 2nd item not the first because sap.m.CustomListItem does not seem to get focus until after the button is pressed.

2. Upon pressing the button I would like to add a status to sap.m.ObjectHeader, once again this is sort of working, on the button press I am doing a .addStatus and the status displays. The issue is that when I press a button on another list item, the status is removed from the original item and displayed on the selected on.

I suspect my issues are all around getting a "handle" on the correct instance of the control in a given list item. Ie, what is the simplest way to refer to a selected instance (maybe by the index) of say sap.m.Input or sap.m.ObjectHeader in a list?

Thanks, Mike