[sapui5] Cannot get control by control Id? See this post
Hello guys,
You maybe sometime frustrated when getting ID of controls of the sapui5 framework, I got the same problem too, when I was starting to work with sapui5.
The root cause that I found the most is forgetting declaring ID for the fragment. Because as sapui5 guideline mentioned, unlike View, Fragment's ID is not generated automatically by the framework. You have to do it by yourself when you initiate the fragment. If you forgot to do this, you won't be able to get the fragment (or controls inside it) using sap.ui.Core.byId() later.
Remember to use this line of code when initiate fragment:
But if you use other function, be aware of the order:
https://sapui5.hana.ondemand.com/sdk/#docs/guide/5da591c5a5a54740948acfe56b22fbc3.html
---V---
You maybe sometime frustrated when getting ID of controls of the sapui5 framework, I got the same problem too, when I was starting to work with sapui5.
The root cause that I found the most is forgetting declaring ID for the fragment. Because as sapui5 guideline mentioned, unlike View, Fragment's ID is not generated automatically by the framework. You have to do it by yourself when you initiate the fragment. If you forgot to do this, you won't be able to get the fragment (or controls inside it) using sap.ui.Core.byId() later.
Remember to use this line of code when initiate fragment:
sap.ui.core.Fragment(sFragmentId, sId)
But if you use other function, be aware of the order:
sap.ui.xmlfragment(sId, sFragmentId, , oController)Example:
this.oDialog = sap.ui.xmlfragment(More details can be found here:
"createProcessDialog","com.HQ.app.test..fragment.CreateProcessDialog", this);
https://sapui5.hana.ondemand.com/sdk/#docs/guide/5da591c5a5a54740948acfe56b22fbc3.html
---V---
Nhận xét
Đăng nhận xét