findNodeByValue not supported in IE7?

7 posts, 0 answers
  1. Mylez
    Mylez avatar
    6 posts
    Member since:
    Feb 2009

    Posted 15 Apr 2009 Link to this post

    From forum post and article I found on your site, I'm using the following to put a new node in edit mode.  When I run it, the page can find the treeview but I get a js error on the bolded line below saying the property/method is not supported by the object. I tried both lower and uppercase 'f' (FindNodeByValue and findNodeByValue) to no avail.  Do you know what might be wrong?

    function HightlightNode(text)
            {
                var node = <%=RadTreeViewProject.ClientID%>.findNodeByValue(text);
                if (node != null)
                {
                    node.StartEdit();
                }

            }
  2. Paul
    Admin
    Paul avatar
    4281 posts

    Posted 16 Apr 2009 Link to this post

    Hello Myla,

    Please find below a sample code snippet that shows the needed approach.

    <body> 
        <form id="form1" runat="server">  
        <telerik:RadScriptManager ID="radscr" runat="server">  
        </telerik:RadScriptManager> 
     
        <script type="text/javascript">  
            function HightlightNode(text) {  
                var node = $find('<%=RadTreeView1.ClientID%>').findNodeByValue(text);  
                if (node != null) {  
                    node.startEdit();  
                }  
            }   
        </script> 
     
        <telerik:RadTreeView ID="RadTreeView1" runat="server" AllowNodeEditing="true">  
            <Nodes> 
                <telerik:RadTreeNode runat="server" Text="Root RadTreeNode1" Value="roo1">  
                    <Nodes> 
                        <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 1" Value="child1">  
                        </telerik:RadTreeNode> 
                        <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 2" Value="child2">  
                        </telerik:RadTreeNode> 
                        <telerik:RadTreeNode runat="server" Text="Child RadTreeNode 3" Value="child3">  
                        </telerik:RadTreeNode> 
                    </Nodes> 
                </telerik:RadTreeNode> 
            </Nodes> 
        </telerik:RadTreeView> 
        <input id="Button1" type="button" value="button" onclick="HightlightNode('child2')" /> 
        </form> 
    </body> 


    Best wishes,
    Paul
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Mylez
    Mylez avatar
    6 posts
    Member since:
    Feb 2009

    Posted 21 Apr 2009 Link to this post

    When using the above recommendation, my js function was still alerting null for the treeview.  I changed 'find' to 'get' and I was able to retrieve the treeview object (the js function alerts '[object]').  When I append .findNodeByValue, I get a js error saying the method isn't supported by the object. The following is what I'm using to test it.  Is there anything else I can try?

    function HightlightNode(text)
            {
                var node = $get('<%=RadTreeViewProject.ClientID%>').findNodeByValue(text);
                alert(node);
            }

  4. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 22 Apr 2009 Link to this post

    Hello Myla Cruz Asthana,

    $get() returns the HTML rendered by RadTreeView whilst $find returns the client-side objects. Can you confirm you are using RadTreeView for ASP.NET Ajax (from the Telerik.Web.UI.dll assembly)? Also do you see any JavaScript errors while your page is loading?

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Mylez
    Mylez avatar
    6 posts
    Member since:
    Feb 2009

    Posted 22 Apr 2009 Link to this post

    Okay, I reverted the 'get' to 'find'.  I do get a JS error on load because after I've selected 'Add IPT' from the context menu, I call the HighlightNode function from serverside to put the new node in edit mode to allow the user to rename it.  The error is for the line of the function and says 'null' is null or not an object.

    <script type="text/javascript">
    function HightlightNode(text)
    {
    var node = $find('<%=RadTreeViewProject.ClientID%>').findNodeByValue(text);
    alert(node);
    }
    </script>

    <div>
    <telerik:RadTreeView ID="RadTreeViewProject" runat="server"
    OnNodeExpand="RadTreeViewProject_NodeExpand"
    OnClientContextMenuItemClicked="onClientContextMenuItemClicking"
    OnContextMenuItemClick="RadTreeViewProject_OnContextMenuItemClick"
    EnableDragAndDrop="true" OnNodeDrop="RadTreeViewProject_OnNodeDrop" Skin="Default"
    AllowNodeEditing="true" OnNodeEdit="RadTreeViewProject_OnNodeEdit">
    <CollapseAnimation Duration="500" Type="OutQuint" />
    <ExpandAnimation Duration="500" />
    <ContextMenus>
    <telerik:RadTreeViewContextMenu runat="server" ID="RadTreeViewContextMenuOther" BorderStyle="solid" BorderColor="blue" BorderWidth="1" DataFieldID="ID" DataFieldParentID="ParentID">
    <Items>
    <telerik:RadMenuItem Text="Add IPT" Value="Add" ImageUrl="ui_assets/images/icon_add.gif" Enabled="true"></telerik:RadMenuItem>
    </Items>
    </telerik:RadTreeViewContextMenu>
    <telerik:RadTreeViewContextMenu runat="server" ID="RadTreeViewContextMenuIPT" BorderStyle="solid" BorderColor="blue" BorderWidth="1" DataFieldID="ID" DataFieldParentID="ParentID">
    <Items>
    <telerik:RadMenuItem Text="Add IPT" Value="Add" ImageUrl="ui_assets/images/icon_add.gif" Enabled="true"></telerik:RadMenuItem>
    <telerik:RadMenuItem Text="Edit IPT Name" Value="Edit" ImageUrl="ui_assets/images/icon_edit.gif" Enabled="true"></telerik:RadMenuItem>
    <telerik:RadMenuItem Text="Delete IPT" Value="Delete" ImageUrl="ui_assets/images/iconDelete.gif" Enabled="true"></telerik:RadMenuItem>
    </Items>
    </telerik:RadTreeViewContextMenu>
    </ContextMenus>
    </telerik:RadTreeView>

    </div>
  6. Mylez
    Mylez avatar
    6 posts
    Member since:
    Feb 2009

    Posted 22 Apr 2009 Link to this post

    Also, this code is inside asp:content tags (inside a master page).  I don't know if this matters or not. 
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 23 Apr 2009 Link to this post

    Hi Myla Cruz Asthana,

    Please let us know how do you call the HightlightNode JavaScript function from server side. Most probably it is called too early - before the treeview is initialized. The correct way to call it is to use the ScriptManager.RegisterStartupScriptMethod and setTimeout:

    ScriptManager.RegisterStartupScriptMethod(this, GetType,
    "setTimeout(function(){
    HightlightNode('MyNode'); }, 0)",
     true);


    All the best,
    Albert
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top