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

findNodeByValue not supported in IE7?

6 Answers 101 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
M
Top achievements
Rank 1
M asked on 15 Apr 2009, 09:51 PM
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();
            }

        }

6 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 16 Apr 2009, 05:42 AM
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.
0
M
Top achievements
Rank 1
answered on 21 Apr 2009, 08:50 PM

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);
        }

0
Atanas Korchev
Telerik team
answered on 22 Apr 2009, 07:42 AM
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.
0
M
Top achievements
Rank 1
answered on 22 Apr 2009, 04:31 PM
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>
0
M
Top achievements
Rank 1
answered on 22 Apr 2009, 06:22 PM
Also, this code is inside asp:content tags (inside a master page).  I don't know if this matters or not. 
0
Atanas Korchev
Telerik team
answered on 23 Apr 2009, 06:18 AM
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.
Tags
TreeView
Asked by
M
Top achievements
Rank 1
Answers by
Paul
Telerik team
M
Top achievements
Rank 1
Atanas Korchev
Telerik team
Share this question
or