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

[Solved] Problem with expanding nodes added on clientside

3 Answers 209 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Andy Wardle
Top achievements
Rank 1
Andy Wardle asked on 17 Jan 2008, 05:05 PM
Hi,

I am currently doing some drag and drop client-side functionality and am comming across some issues when expanding the node using the client-side javascript call RadTreeNode.expand().

The expand call works correctly and the chil nodes are visible in the tree, but the parent node does not have the 'minus' image next to it so the user is not able to collapse the node.

The code I am using is as follows and is called after returning from a WS call :
function OnDragDropComplete(result) 
    if (result != null && result.Successful) 
    { 
        //ctree.trackChanges(); 
        var SourceNode = ctree.findNodeByValue(result.SourceNodeID); 
        var DestNode = ctree.findNodeByValue(result.DestNodeID); 
         
        var childNode = new Telerik.Web.UI.RadTreeNode();  
        childNode.set_value(result.NewNodeID); 
        childNode.set_text(SourceNode.get_text()); 
        childNode.set_imageUrl(SourceNode.get_imageUrl()); 
             
     childNode.get_attributes().setAttribute("Category",SourceNode.get_attributes().getAttribute("Category")) 
        childNode.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack);      
         
        SourceNode.get_parent().get_nodes().remove(SourceNode);    
         
        for(var i = 0; i < DestNode.get_nodes().get_count(); i ++) 
        { 
            if (DestNode.get_nodes().getNode(i).get_text().toLowerCase() > childNode.get_text().toLowerCase()) 
            { 
                DestNode.get_nodes().insert(i,childNode); 
                //alert(DestNode.get_nodes().getNode(i).get_value()); 
                DestNode.get_nodes().getNode(i).expand(); 
                return
            } 
        } 
 
        DestNode.get_nodes().add(childNode); 
        //ctree.commitChanges(); 
        ctree.findNodeByValue(result.NewNodeID).expand();      
    } 

The above code is creating a brand new node instead of just moving the original source node, but I have tried doing it that way as well.

This only happens when using expand(), if I create a child node and add it into the get_nodes() collection the 'minus' appear as expected.

Am I missing something that will stop this happening?

Thanks

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 18 Jan 2008, 09:12 AM
Hi Andy Wardle,

I tried to reproduce the problem in a small and running project, but to no avail. Attached, please find the files. Download them and give them a go.

What am I missing?

Kind regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Andy Wardle
Top achievements
Rank 1
answered on 18 Jan 2008, 11:37 AM
Hi Nick,

Thanks for the reply.

I think the problem I am experiencing is linked into having the ExpandMode being ServerSideCallback.

Below is 2 javascript functions I am using when a user selects the 'replicate' item from a context menu.

function Replicate() 
    var GenericRequest = new IIArc_Web.GenericRequest(); 
    GenericRequest.NodeID = ctree.get_selectedNode().get_value(); 
    IIArc_Web.TreeService.ReplicateNode(GenericRequest, OnReplicateComplete, OnError); 
 
function OnReplicateComplete(result) 
    if (result != null && result.Successful) 
    { 
        //ctree.trackChanges(); 
        var selectedNode = ctree.get_selectedNode(); 
        var childNode = new Telerik.Web.UI.RadTreeNode();  
                 
        childNode.set_value(result.NodeID); 
        childNode.set_text("Copy of " + selectedNode.get_text()); 
        childNode.set_imageUrl(selectedNode.get_imageUrl()); 
        childNode.get_attributes().setAttribute("Category",selectedNode.get_attributes().getAttribute("Category")) 
        childNode.set_expandMode(Telerik.Web.UI.TreeNodeExpandMode.ServerSideCallBack); 
        for (var i = 0; i < selectedNode.get_parent().get_nodes().get_count(); i++) 
        { 
            if (selectedNode.get_parent().get_nodes().getNode(i).get_text() > childNode.get_text()) 
            { 
                selectedNode.get_parent().get_nodes().insert(i, childNode); 
                //ctree.commitChanges(); 
                selectedNode.get_parent().get_nodes().getNode(i).expand(); 
                return
            } 
        } 
    } 

So when the user has replicated a node from the tree, the copy is visible and any child nodes are visible as well. But the new node won't have the 'minus' image next to it.

I am wondering if it is linked into not having the trackChanges() / commitChanges() uncommented (as I am using ServerSideCallback) but when they are uncommented the node that is passed back to the serverside expand handler is null.

I hope I haven't confused things even more!
0
Nikolay
Telerik team
answered on 21 Jan 2008, 03:31 PM
Hello Andy Wardle,

Is it acceptable for you to edit the sample project I attached so that the problem appears. Then, you can paste the exact steps to follow so that I can reproduce the problem at our side. I will test it further and try to find a working solution for you. Another way to proceed would be if you modify the project so that the problem appears and attach the files to a new support thread.

Thanks for your time.

Regards,
Nick
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Andy Wardle
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Andy Wardle
Top achievements
Rank 1
Share this question
or