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

Moving node without a tree root node.

5 Answers 112 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ben Turpin
Top achievements
Rank 1
Ben Turpin asked on 14 Jul 2008, 06:16 PM
Hi!

I have this tree that loads first some folders nodes then some document nodes.
The tree does not have a root node, all this nodes are added directly in the tree like this:

ASPX:
<telerik:RadTreeView  
        ID="DocumentTreeView"  
        Runat="server"  
        LoadingStatusPosition="BeforeNodeText"  
        CssClass="treeContainer"  
        AllowNodeEditing="True"  
        EnableDragAndDrop="True"  
        EnableDragAndDropBetweenNodes="True"  
         
        onnodeexpand="DocumentTreeView_NodeExpand" 
         
        onclientnodedropping="onNodeDropping"  
        onclientnodeediting="onClientEditing" EnableViewState="False" PersistLoadOnDemandNodes="False" 
         
        > 
         
         
         
        <CollapseAnimation Type="OutQuint" Duration="10"></CollapseAnimation> 
 
        <ExpandAnimation Type="OutQuart" Duration="10"></ExpandAnimation> 
    </telerik:RadTreeView> 

Code-behind:
 private void LoadDocsRootNodes() 
    { 
        IEnumerable<Node> folderNodes = DocumentDAO.Create().GetFoldersNodes(); 
 
        LoadTreeRootNodes(DocumentTreeView, folderNodes, "~/Images/icon_small_folder_c.gif""df:"); 
 
        IEnumerable<Node> documentsNodes = DocumentDAO.Create().GetDocumentsNoFoldersNodes(); 
 
        LoadTreeRootNodes(DocumentTreeView, documentsNodes, "~/Images/icon_small_document.gif""dc:"); 
 
    } 
 
private void LoadTreeRootNodes(RadTreeView treeView, IEnumerable<Node> nodes, string imagePath, string itemType) 
    { 
        foreach (Node node in nodes) 
        { 
            RadTreeNode tempNode = new RadTreeNode(); 
 
            tempNode.Text = node.Text; 
            tempNode.Value = itemType + node.Id; 
 
            tempNode.ImageUrl = imagePath; 
 
            tempNode.ExpandMode = (node.HasChilds || node.HasIntroDocument) ? TreeNodeExpandMode.ServerSideCallBack : TreeNodeExpandMode.ClientSide; 
 
 
            treeView.Nodes.Add(tempNode); 
        } 
    } 
 

My problem is when I try to move a document node to a folder node.
It throws this error:
"htmlfile: Invalid argument."
and then shows this in the Telerik.Web.UI.Common.Core.js I think
"_ba.get_childListElement().removeChild(this.get_element());"

I did test with a new project and the error did not happen, it moves normally even if the destination node does not have a father node. My real problem is that is hard to track/debug this issue. I simply do a insert

var destNodes = tempDestNode.get_nodes();
destNodes.insert(0,tempSourceNode); // .add() doesn't work either...

Any help?

Thanks.

5 Answers, 1 is accepted

Sort by
0
Ben Turpin
Top achievements
Rank 1
answered on 14 Jul 2008, 06:22 PM
Another thing is if I create a new node it works fine:

var newNode = CloneNode(tempSourceNode); 
var destNodes = tempDestNode.get_nodes(); 
destNodes.add(newNode); 
 
function CloneNode(node) 
    var newNode = new Telerik.Web.UI.RadTreeNode(); 
    newNode.set_text(node.get_text()); 
    newNode.set_value(node.get_value()); 
    newNode.set_imageUrl(node.get_imageElement().src); 
     
    return newNode; 

Thanks in advance.
0
Simon
Telerik team
answered on 15 Jul 2008, 11:10 AM
Hi Ben Turpin,

I tried to reproduce the problem but to no avail.

Please examine the attached project. How can I modify it so that the error starts to appear?

All the best,
Simon
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Ben Turpin
Top achievements
Rank 1
answered on 17 Jul 2008, 01:27 PM
Hi Simon, thanks for the reply.

Well it did rise an error, but it was different. My raises something releated to "_ba.get_childListElement().removeChild(this.get_element())" and yours to
"Array.insert(_cc,0,_cd.get_index());"
Im not sure how this can help but at least you can see how is a bit complicated to track down the bug.

here is the modified code:
        function onNodeDropping(sender, eventArgs) 
        { 
            //eventArgs.get_destNode().get_nodes().insert(0, eventArgs.get_sourceNode()); 
             
            var sourceNode = eventArgs.get_sourceNode(); 
            var destNode = eventArgs.get_destNode(); 
             
            var parentNode = destNode.get_parent(); //Ok 
            var nodes = parentNode.get_nodes(); //Ok 
            nodes.remove(sourceNode); //Error Rises  
 
//            sourceNode.get_parent().get_nodes().removeAt(4); //Error Rises 
        } 

Thanks.



0
Ben Turpin
Top achievements
Rank 1
answered on 17 Jul 2008, 06:01 PM

Another tricky thing.
There is a ghost node here. This node only appears when I hover the mouse over it. Its an null node with no image, it just shift the nodes below and opens a space between when I pass the mouse over it.
The intresting fact is that every node before this node I can delete fine, but this 'ghost' node and every node below it throws the error that I just described.
Ah, in FireFox 3 works fine. No error at all.

Thanks
0
Ben Turpin
Top achievements
Rank 1
answered on 17 Jul 2008, 07:09 PM
Well I called the ghostbusters and they helped me out here...

The problem was that there was a node coming from the database with this text "a_XML<nodkhdakshd"  and it was showing on the treeview just "a_XML" and every thing below it was kinda working fine (dont ask me how).
This '<nodkhdakshd' created the ghost node and created this potential bug. So I just used the HtmlEncode and it worked.

Any way I spent quite some time to figure this out, I wished there were an easier way to debug these kind of issues.

Any way, thanks again.
Happy coding!
Tags
TreeView
Asked by
Ben Turpin
Top achievements
Rank 1
Answers by
Ben Turpin
Top achievements
Rank 1
Simon
Telerik team
Share this question
or