[英]SAPUI5 Set Focus on Input Field
i have the following Problem:我有以下问题:
I have 2 XML Views with a few input fields and at navigation to the second view the focus should be on the 5th(ID = "RueckmeldeNr") field.我有 2 个带有几个输入字段的 XML 视图,在导航到第二个视图时,焦点应该放在第 5 个(ID = "RueckmeldeNr")字段上。
I tried several things but nothing worked.. If i use the jQuery delayedCall the focus shortly flashes on the input field but is instantly set to the NavBack Button in the upper left corner.我尝试了几件事,但没有任何效果。如果我使用 jQuery 延迟调用,焦点会在输入字段上短暂闪烁,但会立即设置为左上角的 NavBack 按钮。
Do i use the method false or forget something?我是使用 false 方法还是忘记了什么? How can i solve this?我该如何解决这个问题?
onAfterRendering : function(oEvent) {
oInputRueck = this.getView().byId("RueckmeldeNr");
// this.getView().byId("RueckmeldeNr").focus();
// this.getView().byId("RueckmeldeNr").$().focus();
// jQuery.sap.delayedCall(200, this, function() {
// //this.getView().byId("RueckmeldeNr").focus();
// oInputRueck.focus();
// });
// var oFocusInfo = this.getView().byId("RueckmeldeNr").getFocusInfo()
// this.getView().byId("RueckmeldeNr").applyFocusInfo(oFocusInfo);
jQuery.sap.delayedCall(0, this, function() {
oInputRueck.focus();
});
},
I hope you can help me!我希望你可以帮助我!
Thank you谢谢
Just a suggestion:只是一个建议:
You could set focus to the required field in the view (or where ever you define it).您可以将焦点设置到视图中的所需字段(或您定义它的任何地方)。
For example, in view1 you define:例如,在 view1 中定义:
var oInput = new sap.m.Input({id: "inputID"})
.addEventDelegate({
onAfterRendering: function(){
oInput.focus();
}
});
and then, when you call the view, the focus should be set to the required field automatically.然后,当您调用视图时,焦点应自动设置为必填字段。
Answer is solved by myself.答案是我自己解决的。
I just put the delayedCall on 500 miliseconds and it worked.我只是将 delayCall 设置为 500 毫秒并且它起作用了。
jQuery.sap.delayedCall(500, this, function() {
this.getView().byId("RueckmeldeNr").focus();
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.