Skip to Content

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

How to get an Control using the byId? But the Control is inside a list, and this list is inside a fragment.

Hi, How to get an Control using the byId? But the Control is inside a list, and this list is inside a fragment. This is the code to add the fragment:

This is the fragment:

In the controller, all of these return undefined:

this.getView().byId("myIpt")

sap.ui.core.Fragment.byId("myFragment","myIpt")

sap.ui.getCore().byId("myIpt")

* As you can see in the input I have add an event the liveChange, with a breakpoint I can see that the input Id is:

oControlEvent.getSource().getId() === "__xmlview3--create--myFragment--myIpt-__xmlview3--create--myFragment--myList-0"

The only way I found to get the input was by removing the id from the fragment ("myFragment") and with the following:

this.getView().byId("myList").getItems()[0].getContent()[0].getItems()[2]

Bu in my opinion this is going to give me a lot of headaches in the future with maintenance.

What I want to do is something similar to "byId", but it is not working, so I need help to understand why this does not work, and directions to the best solution.

thanks Cristiano.

Tags:
replied

hi,

to solve that problem I have used sap.ui.core.Fragment.byId(fragmentId, controlId);

thanks to all for the tips, Cristiano.

0 View this answer in context

Helpful Answer

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