I am trying to focus the AutoCompleteBox racInput but got no success. I tried this:
function pageLoaded() {
var radInput = $find("<%= RadAutoCompleteBox1.ClientID %>");
radInput.focus();
//console.log(document.getElementById('RadAutoCompleteBox1'));
}
<body onload="pageLoaded()">
Any idea?
3 Answers, 1 is accepted
0
Vessy
Telerik team
answered on 21 Jan 2021, 03:01 PM
Hi Yan,
The client-side object of RadAutoComplete control does not expose a focus() method. If you want to call the focus() of its input element, you will first need to access the input using the get_inputElement() method.
The client-side API of the control can be found here:
I will also advice to do that in the client-side Load handler of the control in order to ensure that the client-object is loaded and accessible:
<telerik:RadAutoCompleteBoxRenderMode="Lightweight"runat="server"ID="RadAutoCompleteBox1"EmptyMessage="Please type here"AllowCustomEntry="false"DataSourceID="SqlDataSource1"DataTextField="FirstName"OnClientLoad="onClientLoad"InputType="Text"Width="350"DropDownWidth="150px"></telerik:RadAutoCompleteBox><script>functiononClientLoad(autoComplete, args) {
var radInput = autoComplete.get_inputElement();
radInput.focus();
}
</script>
Regards,
Vessy
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
In fact I realized that it WAS getting the focus but due to an issue in the EmptyMessage feature I was not seeing it.
0
Vessy
Telerik team
answered on 22 Jan 2021, 05:31 PM
Hi,
You are welcome, Yan :)
Regards,
Vessy
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.