[英]How to focus a SAP UI5 SmartFilterBar SearchField?
I'm adding a basic SearchField with the SmartFilterBar in SAP UI5.我在 SAP UI5 中使用 SmartFilterBar 添加了一个基本的 SearchField。 How can I set the focus of the input field in the basic search field?
如何在基本搜索字段中设置输入字段的焦点?
<Page id="idMaster" showHeader="true">
<content>
<smartFilterBar:SmartFilterBar
id="idMasterFilterBar"
basicSearchFieldName="vbeln"
enableBasicSearch="true">
<smartFilterBar:controlConfiguration>
<smartFilterBar:ControlConfiguration id="idSmartFilterBarConfiguration"/>
</smartFilterBar:controlConfiguration>
</smartFilterBar:SmartFilterBar>
<.../>
</content>
</Page>
Tried this without success:试过这个没有成功:
onAfterRendering: function () {
const that = this
jQuery.sap.delayedCall(5000, null, function () {
const searchFieldId = that.byId('idMasterFilterBar').getBasicSearch()
const searchField = that.byId(searchFieldId)
searchField.focus();
});
},
or that...或者那个...
onAfterRendering: function () {
jQuery.sap.delayedCall(5000, null, function () {
const element = document.querySelector("[type=search]");
element.focus();
});
},
Solved:解决了:
After restarting the application with npm run and starting the app fresh from the launchpad, it works.使用 npm run 重新启动应用程序并从启动板重新启动应用程序后,它就可以工作了。
onAfterRendering: function () {
jQuery.sap.delayedCall(500, null, function () {
const element = document.querySelector("[type=search]");
element.focus();
});
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.