SAPUI5将焦点设置在输入字段上 [英] SAPUI5 Set Focus on Input Field
问题描述
我有以下问题:
我有2个带有几个输入字段的XML视图,导航到第二个视图时焦点应该是5号(ID =RueckmeldeNr)字段。
我尝试了几样但没有任何效果..
如果我使用jQuery delayedCall,焦点会在输入字段上快速闪烁但是立即设置为左上角的NavBack按钮。
我是使用false方法还是遗忘?我该如何解决这个问题?
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();
});
},
我希望你能帮助我!
谢谢你
只是一个建议:
你可以将焦点设置为视图中的必填字段(或您定义的地方)。
例如,在view1中定义:
var oInput = new sap.m.Input({id:inputID})
.addEventDelegate({
onAfterRendering:function(){
oInput.focus();
}
});
然后,当您调用视图时,焦点应自动设置为必填字段。 / p>
这是一个有效的JSBIN示例:链接
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.
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.
Do i use the method false or forget something? 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:
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.
Here is a working JSBIN example: LINK
这篇关于SAPUI5将焦点设置在输入字段上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!