1

I'm trying to access an input control in the controller but I'm not able to fetch it.

I'm using

sap.ui.getCore().byId("id of the input");
Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
  • Does this answer your question? [Difference Between this.getView().byId(), this.byId(), and sap.ui.getCore().byId()](https://stackoverflow.com/questions/48639302/difference-between-this-getview-byid-this-byid-and-sap-ui-getcore-byid) – Boghyon Hoffmann Aug 21 '20 at 12:34

3 Answers3

1

I faced a similar issue when I started using UI5. The id is not the same anymore because Sap UI5 dynamically concatenates some other properties to your id so it will be different. Hope this helps. try finding out the id after it has been changed by the resources.

codemania23
  • 913
  • 11
  • 19
1

Try the following:

this.byId('controlId')

Or:

this.getView().byId('controlId')

See Difference Between this.getView().byId(), this.byId(), and sap.ui.getCore().byId()

Boghyon Hoffmann
  • 17,103
  • 12
  • 72
  • 170
Chris Neve
  • 2,164
  • 2
  • 20
  • 33
1

https://openui5.hana.ondemand.com/#docs/guide/91f28be26f4d1014b6dd926db0e91070.html Hope this doc will help you.

You should use relative navigation(this.getView().byId('myId')). Absolute Navigation(sap.ui.getcore().byId('myId')) is not recommended, since that will not work anymore if you change like local project to FioriLaunchpad.

I think the source code of byId of Controller and createId of View explains a lot.

Tina Chen
  • 2,010
  • 5
  • 41
  • 73