How do I give keyboard focus to a templated Item in a Combobox?

2 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 23 Jan 2013 Link to this post

    I have a RadComboBox that has a single templated item that is a RadTreeView.

    I'm looking for suggestions about how I might go about giving the RadTreeView keyboard focus when the RadCombobox's dropdown is opened.

    Assume my markup is simpliar to this ...
    <telerik:RadComboBox runat="server"
            <telerik:RadTreeView ID="RadTreeView1"
                    <telerik:RadTreeNode Text="Node 1" Value="1" /> 
                    <telerik:RadTreeNode Text="Node 2" Value="2" Selected="true" /> 
                    <telerik:RadTreeNode Text="Node 3" Value="3" /> 

    Where the ComboFocus function simply opens the dropdown.

    So, what I'm trying to establish is, is there anyway I can - programmatically - give my treeview control of the keyboard?


  2. Answer
    Boyan Dimitrov
    Boyan Dimitrov avatar
    1728 posts

    Posted 28 Jan 2013 Link to this post

    Hello Stuart,

    An easy and convenient way of achieving that functionality would be to enable the keyboard support for the RadTreeView control by setting TabIndex="1".
    Additionally you could focus its DOM element using OnClientFocus or OnClientDropDownOpened client-side event of the RadComboBox control.
    Please find an sample implementation of that approach in the code snippet below:
    //markup code
    <telerik:RadComboBox ID="RadComboBox1" OnClientDropDownOpened="OnClientDropDownOpenedHandler">
                    <div id="div1">
                        <telerik:RadTreeView ID="RadTreeView1" runat="server" TabIndex="1"/>
    function OnClientDropDownOpenedHandler(sender, eventArgs) {          
        var tree = sender.get_items().getItem(0).findControl("RadTreeView1");
        var selectedNode = tree.get_selectedNode();
        if (selectedNode) {

    Boyan Dimitrov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. DevCraft R3 2016 release webinar banner
Back to Top