This is a migrated thread and some comments may be shown as answers.

SetFocus to Textbox inside RadTreeviewContextMenu

4 Answers 70 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
orim
Top achievements
Rank 1
orim asked on 24 May 2013, 04:05 PM
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>

4 Answers, 1 is accepted

Sort by
0
Accepted
Hristo Valyavicharski
Telerik team
answered on 29 May 2013, 01:38 PM
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.
0
Syed
Top achievements
Rank 1
answered on 20 Nov 2013, 08:32 AM
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
0
Syed
Top achievements
Rank 1
answered on 21 Nov 2013, 01:25 PM
How To Set focus On Textbox 
Control Inside RadTreeList After Validation On Tab Press , In that Particular Node ,Current Row

Please Help

Regards

Hussain
0
Viktor Tachev
Telerik team
answered on 22 Nov 2013, 02:56 PM
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.
Tags
TreeView
Asked by
orim
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Syed
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or