Set focus on filter input OnClientDropDownOpened with Dropdowntree control

2 Answers 138 Views
DropDownTree
David
Top achievements
Rank 1
Iron
David asked on 06 Jul 2022, 11:45 AM

Hi, I'm trying to put focus on filter input in DropdownTree control when dropdown is opened but I can't get it. I've tryed with some code like this but without success:

 

JS:
            function SetFilterFocus(sender,argEvent){
                sender.get_filterElement().focus();
            }

ASP.NET
                                            <telerik:RadDropDownTree CssClass="RadComboBox_Metro" Skin="Metro" runat="server" ID="ddt_centro" AutoPostBack="true" Width="90%" TabIndex="3" DataTextField="FMODES" DataFieldID="FMOFAM" TextMode="Default" DataFieldParentID="FMOZU1" OnClientEntryAdding="OnClientEntryAdding" ExpandNodeOnSingleClick="true" CheckNodeOnClick="true" EnableFiltering="true" OnClientDropDownOpened="SetFilterFocus">
                                                <FilterSettings Filter="Contains" Highlight="Matches" MinFilterLength="3" />
                                                <DropDownSettings CssClass="RadComboBox_Metro" Height="300px" CloseDropDownOnSelection="true" />
                                            </telerik:RadDropDownTree>

 

 

Is it possible to do this?

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 07 Jul 2022, 02:59 PM

Hi David,

You would need to wrap the focus logic in a setTimeout as the focus is lost if set while the dropdown opening animation still goes:

function OnClientDropDownOpened(sender, args) {
    setTimeout(function () {
        sender.get_filterElement().focus();
    },150)
}

Regards,
Peter Milchev
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/.

0
David
Top achievements
Rank 1
Iron
answered on 08 Jul 2022, 06:19 AM
Thanks, it works perfect!!!!!!
Tags
DropDownTree
Asked by
David
Top achievements
Rank 1
Iron
Answers by
Peter Milchev
Telerik team
David
Top achievements
Rank 1
Iron
Share this question
or