How completely disable selected state of nodes in RadTreeView

7 posts, 1 answers
  1. Ivan Petrov
    Ivan Petrov avatar
    23 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Problem: I need to completely disable selected state of nodes in RadTreeView.

    I attach OnClientNodeClicking and OnClientKeyPressing to RadTreeView.

    Please, try this markup. It shows strange behaviour:

    Step 1. I expand 'Node 1' by clicking on plus image ([+])
    Step 2. Now I press 'Enter' (or 'Up', 'Down') key
            ... and .. first node is selected! (In spite of the fact that I used OnClientKeyPressing)

    If in step 1 I expand 'Node 1' by double clicking on text of node  -  in step 2 node not selected (normal behaviour)

        <form id="form1" runat="server">   
        <asp:ScriptManager ID="ScriptManager1" runat="server" />       
        <div>  
          <telerik:RadTreeView ID="RadTreeView1" runat="server"  
             OnClientKeyPressing="OnClientKeyPressing"  
             OnClientNodeClicking="OnClientNodeClicking">   
            <Nodes>  
              <telerik:RadTreeNode Text="Node 1">   
                <Nodes>  
                  <telerik:RadTreeNode Text="Node 1_1" Value="1_1"></telerik:RadTreeNode>  
                  <telerik:RadTreeNode Text="Node 1_2" Value="1_2"></telerik:RadTreeNode>  
                </Nodes>  
              </telerik:RadTreeNode>  
            </Nodes>  
          </telerik:RadTreeView>  
        </div>  
        </form>  
    <script type="text/javascript">   
      function OnClientKeyPressing(sender, args) {   
        args.set_cancel(true);   
      }   
      function OnClientNodeClicking(sender, args) {   
        args.set_cancel(true);   
      }   
    </script>  

  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 24 Nov 2009 Link to this post

    Hello,

    I have created test page. using your code and new Rad Project.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"
    <head runat="server"
        <title></title
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" /> 
    </head> 
    <body> 
        <form id="form1" runat="server"
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
                <Scripts> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> 
                    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> 
                </Scripts> 
            </telerik:RadScriptManager> 
            <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            </telerik:RadAjaxManager> 
            <div> 
                <telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientKeyPressing="OnClientKeyPressing" 
                    OnClientNodeClicking="OnClientNodeClicking"
                    <Nodes> 
                        <telerik:RadTreeNode Text="Node 1"
                            <Nodes> 
                                <telerik:RadTreeNode Text="Node 1_1" Value="1_1"
                                </telerik:RadTreeNode> 
                                <telerik:RadTreeNode Text="Node 1_2" Value="1_2"
                                </telerik:RadTreeNode> 
                            </Nodes> 
                        </telerik:RadTreeNode> 
                    </Nodes> 
                </telerik:RadTreeView> 
            </div> 
        </form> 
     
        <script type="text/javascript">    
      function OnClientKeyPressing(sender, args) {    
        args.set_cancel(true);    
      }    
      function OnClientNodeClicking(sender, args) {    
        args.set_cancel(true);    
      }    
        </script> 
     
    </body> 
    </html> 
     

    Your code seems to be working in FF 3.5.5 . None of the nodes are selected by key or click.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ivan Petrov
    Ivan Petrov avatar
    23 posts
    Member since:
    Nov 2009

    Posted 24 Nov 2009 Link to this post

    Hello, Roland!
    Yes, really, in FF 3.5 your code is working.
    But in Internet Explorer 8 first node is selected! (If you click on [+] image and press 'Enter' key)
    See attached image.

    Whether there is a elegant solution of this problem?
  5. Schlurk
    Schlurk avatar
    812 posts
    Member since:
    May 2009

    Posted 24 Nov 2009 Link to this post

    I did some experimenting with your implementation and IE8  and sure enough it seems as if on the initial pressing the enter/up/down keys do not fire an event in IE. I event went as far as so set up this line:

     
    <body onkeypress="return false" onkeydown="return false"

    This worked fine in FF and Opera, but not IE (8 and 8 in compatibility mode). It seems like it takes until the second key press before the proper events are fired. Almost seems like there's something going on with the javascript engine of IE :|
  6. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 24 Nov 2009 Link to this post

    Hello again,

    I contacted Telerik once regarding IE8 and some other problem. They said that IE8 is invoking script intended for other browsers.

    This may be the case here. Besides, even normal MS ajax scripts are throwing exceptions in IE8 in my project.

    Unfortunately if IE8 is requirement :S its a pain.
  7. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 25 Nov 2009 Link to this post

    Hi Ivan,

    Please check this forum post regarding the same issue.

    Regards,
    Yana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. Ivan Petrov
    Ivan Petrov avatar
    23 posts
    Member since:
    Nov 2009

    Posted 25 Nov 2009 Link to this post

    Thanks a lot, Yana. Your method is working.
    Thanks All for Your help.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017