SetFocus to Textbox inside RadTreeviewContextMenu

5 posts, 1 answers
  1. orim
    orim avatar
    29 posts
    Member since:
    Mar 2012

    Posted 24 May 2013 Link to this post

    Hi,
    how can i set focus on textbox (TextboxFindTreeNode), after opening ContextMenu with right click.
    I user the ItemTemplate in RadMenuItem
    Thanks
    <telerik:RadTreeView ID="RadTreeViewFileShare" runat="server" >
     
                 <ContextMenus>
     
                     <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenuFs" runat="server">
                         <Items>
                             <telerik:RadMenuItem>
                                 <ItemTemplate>
                                     <asp:Panel ID="PanelFindNode" runat="server" style="padding:5px;" DefaultButton="ButtonFindTreeNode">
                                   
                                     <asp:Label ID="LabelFindNode" runat="server" Text="Find Node:" AssociatedControlID="TextBoxFindTreeNode"></asp:Label
                                     <asp:TextBox ID="TextBoxFindTreeNode" runat="server" AutoCompleteType="Search"></asp:TextBox>
                                     <asp:ImageButton ID="ButtonFindTreeNode" runat="server" ImageUrl="~/Images/Search/Search.ico"
                                         ToolTip="Search for node" OnClick="ButtonFindTreeNode_Click" ImageAlign="Middle"/>
                                    </asp:Panel>
                                 </ItemTemplate>
                             </telerik:RadMenuItem>
                         </Items>
     
     
                     </telerik:RadTreeViewContextMenu>
                 </ContextMenus>
         </telerik:RadTreeView>
  2. Answer
    Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 29 May 2013 Link to this post

    Hi Orim,

    You could handle OnClientContextMenuShowing event and focus the text input using jQuery:
    <telerik:RadTreeView ID="RadTreeViewFileShare" runat="server" OnClientContextMenuShowing="OnClientContextMenuShowing">
                  <ContextMenus>
     
                      <telerik:RadTreeViewContextMenu ID="RadTreeViewContextMenuFs" runat="server">
                          <Items>
                              <telerik:RadMenuItem>
                                  <ItemTemplate>
                                      <asp:Panel ID="PanelFindNode" runat="server" Style="padding: 5px;" DefaultButton="ButtonFindTreeNode">
     
                                          <asp:Label ID="LabelFindNode" runat="server" Text="Find Node:" AssociatedControlID="TextBoxFindTreeNode"></asp:Label>
                                          <asp:TextBox ID="TextBoxFindTreeNode" runat="server" AutoCompleteType="Search" CssClass="search"></asp:TextBox>
                                          <asp:ImageButton ID="ButtonFindTreeNode" runat="server" ImageUrl="~/Images/Search/Search.ico"
                                              ToolTip="Search for node" OnClick="ButtonFindTreeNode_Click" ImageAlign="Middle" />
                                      </asp:Panel>
                                  </ItemTemplate>
                              </telerik:RadMenuItem>
                          </Items>
     
     
                      </telerik:RadTreeViewContextMenu>
                  </ContextMenus>
                  <Nodes>
                      <telerik:RadTreeNode Text="Root" Selected="true">
                          <Nodes>
                              <telerik:RadTreeNode Text="Child"></telerik:RadTreeNode>
                          </Nodes>
                      </telerik:RadTreeNode>
                  </Nodes>
              </telerik:RadTreeView>

    function OnClientContextMenuShowing(sender, args) {
        setTimeout(function () {
            $('.search').focus();
        }, 200);
    }

    Note that I added custom css class to the 'TextBoxFindTreeNode' for easier selection.

    Regards,
    Hristo Valyavicharski
    Telerik
    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. UI for ASP.NET Ajax is Ready for VS 2017
  4. Syed
    Syed avatar
    3 posts
    Member since:
    Nov 2013

    Posted 20 Nov 2013 Link to this post

    How To Set focus On Textbox 
    Control Inside RadTreeList After Validation On Tab Press , It May be on Any no Row Control Please Help Me
  5. Syed
    Syed avatar
    3 posts
    Member since:
    Nov 2013

    Posted 21 Nov 2013 Link to this post

    How To Set focus On Textbox 
    Control Inside RadTreeList After Validation On Tab Press , In that Particular Node ,Current Row

    Please Help

    Regards

    Hussain
  6. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 22 Nov 2013 Link to this post

    Hello Hussain,

    Would you elaborate more on what is the scenario you are trying to achieve. Are the TextBox controls in the EditForm for RadTreeList item or somewhere else?

    Generally you could attach handler for the onkeydown event for a given TextBox and set focus to the control you would like. Getting reference to controls in RadTreeList Items and cells is illustrated in this article.

    I would also appreciate it if you could share your markup code with the code-behind. This would enable us to better understand your scenario and provide an appropriate solution.

    Regards,
    Viktor Tachev
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017