findNodeByValue returns null after refreshing parent node

3 posts, 0 answers
  1. Inge
    Inge avatar
    2 posts
    Member since:
    Jan 2012

    Posted 01 Mar 2012 Link to this post

    Hi everyone,

    I am having a problem refreshing a node after saving changes on the server side.  A summary:

    I have an ASP.NET Ajax RadTreeView within an UpdatePanel.  A user selects a node and clicks an Edit button.  This opens a jQuery dialog in which node data can be changed, such as the description (not the value!).  After clicking the Save button in the dialog, a piece of JavaScript triggers a button, which has been registered for AsyncPostBack.  On the server side, the node data is saved, and execution returns to a JavaScript method on the page.  I then want to refresh the node that has been edited, in order to display, for instance, the new description for the node.  I might be going about this the wrong way, but I thought I would be able to accomplish this by refreshing the node's parent, and then re-selecting the node itself.  Everything works, accept re-selecting the node that had been edited. 

    I write the following code:

    var tree = FindTree();
    var currentNodeValue = tree.get_selectedNode().get_value();
    var currentNode = tree.findNodeByValue(currentNodeValue);
    // TODO: why is this node not found?!?
    // For now, after update, the parent is selected because the child node is not found, even though it is there...
    if (currentNode) {;

    The RefreshParentNode function simply finds the parent node of the selected node, and then refreshes it using the following code:

    function RefreshNode(node) {
        if (node) {

    All nodes are now displayed correctly, including the updated node with its new description.  However, as the comments in the code fragment at the top show, the findNodeByValue function fails to find the node that had been edited, so I can't re-select it.

    So, I basically, have two questions:

    1) Is there an easier way to get the edited node to display its new description?
    2) If not: why is the node not found by findNodeByValue after refreshing the parent, and how can I fix this?

    By the way, in case this is not clear from the code fragments above: I am using a LoadOnDemand scenario.  Root nodes are loaded immediately, child nodes are loaded using a webservice.

    UPDATE: Yes, the FindTree method uses $find and not $get.  The tree reference is not the problem...

  2. Dimitar Terziev
    Dimitar Terziev avatar
    1266 posts

    Posted 05 Mar 2012 Link to this post

    Hi Inge,

    The problem in your case might be caused by a timing issue, since you are trying to find the edited node  immediately after you have cleared the nodes of its parent and a new request for nodes has been made. Please try to preselect your edited item once the OnClientNodePopulated event is fired. This way you will ensure that the request for nodes is finished.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    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. Inge
    Inge avatar
    2 posts
    Member since:
    Jan 2012

    Posted 05 Mar 2012 Link to this post

    Thank you!  That was exactly what I was looking for.
Back to Top