admin管理员组文章数量:1394149
I am creating an application enable user to dynamically add new label and input into form. But I have set the new input id and enabled is false dynamically added by user. But when I click edit button, enabled set to true. It does not work. My application cant read the input id that I added dynamically in form.
The following is my sample code.
Add new label and input into my current form
var _oSF2 = this.getView().byId("Extension_Form");
_oSF2.addContent(new sap.m.Label({
text: "Classification"
}));
_oSF2.addContent(new sap.m.Input({
id : "idExtensionInput1",
text : "text",
enabled: false
}));
Set enablement for new input to true
handleEditPress: function () {
this.getView().byId("idExtensionInput1").setEnabled(true);
}
I am creating an application enable user to dynamically add new label and input into form. But I have set the new input id and enabled is false dynamically added by user. But when I click edit button, enabled set to true. It does not work. My application cant read the input id that I added dynamically in form.
The following is my sample code.
Add new label and input into my current form
var _oSF2 = this.getView().byId("Extension_Form");
_oSF2.addContent(new sap.m.Label({
text: "Classification"
}));
_oSF2.addContent(new sap.m.Input({
id : "idExtensionInput1",
text : "text",
enabled: false
}));
Set enablement for new input to true
handleEditPress: function () {
this.getView().byId("idExtensionInput1").setEnabled(true);
}
Share
Improve this question
edited Nov 16, 2018 at 15:32
Jaro
1,7541 gold badge16 silver badges36 bronze badges
asked Aug 28, 2018 at 3:31
Chan Yoong HonChan Yoong Hon
1,8227 gold badges37 silver badges73 bronze badges
2
- did you look if your control has the ID via F12 Elements Tab? – Erch Commented Aug 28, 2018 at 5:17
- Yes, it have ID with "idExtensionInput1-inner" – Chan Yoong Hon Commented Aug 28, 2018 at 6:20
1 Answer
Reset to default 4You've added the input to no view. In your case, you can only access the input with sap.ui.getCore().byId("idExtensionInput1")
but the correct way is to use this.getView().createId()
and add it to the right view.
var _oSF2 = this.getView().byId("Extension_Form");
_oSF2.addContent(new sap.m.Label({
text: "Classification"
}));
<!-- language: lang-js -->
_oSF2.addContent(new sap.m.Input({
id : this.getView().createId("idExtensionInput1"), //Use createId() for this.getView()
text : "text",
enabled: false
}));
handleEditPress: function () {
this.getView().byId("idExtensionInput1").setEnabled(true);
}
One ment: The first parameter for new sap.m.Input is the id. Please write:
_oSF2.addContent(new sap.m.Input(this.getView().createId("idExtensionInput1"), {
text : "text",
enabled: false
}));
版权声明:本文标题:javascript - SAPUI5 Form Add Label and Input dynamically and set ID for Input but not function - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744733847a2622205.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论