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

[Solved] Cleared nodes get displayed again, node images are missing too

5 Answers 144 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Markus
Top achievements
Rank 2
Markus asked on 22 Jan 2008, 08:31 AM
Hello everybody!

I'm using a RadTreeView control and implemented LoadonDemand. Whenever a node gets expanded, or the page gets loaded for the first time, I load the childelements of the node too, to estimate whether to display the expand item or not.

This code gets called when i load the page for the first time (or refresh it):


            ParameterTreeView.Nodes.Clear(); 
            ICollection<IHierarchyElement> rootColl = treeStructureService.ParameterRootElements(); 
            foreach (IHierarchyElement element in rootColl) 
            { 
                RadTreeNode node = CreateNode(element); 
                ICollection<IHierarchyElement> childColl = treeStructureService.ParameterChildElements(node.Value); 
                foreach (IHierarchyElement childElement in childColl) 
                { 
                    RadTreeNode cNode = CreateNode(childElement); 
                    node.Nodes.Add(cNode); 
                } 
                ParameterTreeView.Nodes.Add(node); 
            } 

Creating a node happens like that:

private static RadTreeNode CreateNode(IHierarchyElement element) 
        { 
            RadTreeNode node = new RadTreeNode(element.Denotation); 
            node.Value = element.Id; 
            node.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; 
            node.ImageUrl = "~/RadControls/Treeview/Skins/ExampleSkins/ContextMenu/Folder.gif"
            node.ExpandedImageUrl = "~/RadControls/Treeview/Skins/ExampleSkins/ContextMenu/FolderOpen.gif"
            return node; 
        } 

and expanding a node like that:

foreach (RadTreeNode node in _root.Nodes) 
            { 
                //RadTreeNode node = CreateNode(element); 
                ICollection<IHierarchyElement> childColl = treeStructureService.ParameterChildElements(node.Value); 
                 
                foreach (IHierarchyElement child in childColl) 
                { 
                    RadTreeNode childNode = CreateNode(child); 
                    node.Nodes.Add(childNode); 
                } 
            } 

My Problems in short:

Whenever i refresh the page and expand the root items again, already deleted items are shown.
The node items are only shown in layer 1 and 2. Everything beneath these layers has no items.
After refreshing, the duplicate items are missing the images too.

5 Answers, 1 is accepted

Sort by
0
Markus
Top achievements
Rank 2
answered on 22 Jan 2008, 09:23 AM
Whenever I refresh the page, the TreeViewNodesCollection is empty without deleting them beforehand. Allthough the old nodes are shown
0
Dimitar Milushev
Telerik team
answered on 23 Jan 2008, 12:08 PM
Hi Markus,

Can you please open a support ticket and send us a sample project that demonstrates the issue you are having? This will make it much easier for us to understand the logic of your project, debug the problem and suggest you a solution.

Thank you for your understanding.

Regards,
Dimitar Milushev
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Timothy Robbins
Top achievements
Rank 1
answered on 04 Feb 2008, 09:44 PM
I gather this person's issue with the nodes duplication was likely not setting the current node to expanded and setting the expandmode to client during the callback.

But what about the images?

during creation of a node, i set the imageurl to a given path.
however. after doing a postback, which hides and shows the tree's parent panel, all images in the imageurl are lost. This occurs in both firefox and ie.


RadTreeNode tn = new RadTreeNode(i.Name);
tn.Value = "I-" + i.Id.ToString();
tn.ImageUrl = "~/Images/Box.png";
e.Node.Nodes.Add(tn);
0
Markus
Top achievements
Rank 2
answered on 05 Feb 2008, 08:10 AM
[quote]
I gather this person's issue with the nodes duplication was likely not setting the current node to expanded and setting the expandmode to client during the callback.
[/quote]

Could you please explain how nodes duplication and ExpandMode Settings play together in this case? And further how I can avoid this duplication issue.

Btw I found out that the nodes duplication issue doesn't happen with IE6
0
Timothy Robbins
Top achievements
Rank 1
answered on 05 Feb 2008, 03:02 PM
Sure. Best to look at their demo.
From the c# source:
foreach
(DataRow row in data.Rows)
{
//<snip> new child node creation here
}
e.Node.Expanded = true;
e.Node.ExpandMode = TreeNodeExpandMode.ClientSide;


I had the same issue if i used the tool in the manner I felt was obvious. My mistake though, its not immediately obvious why you have to do it this way, but if you think about it, you'll get it.
Tags
TreeView
Asked by
Markus
Top achievements
Rank 2
Answers by
Markus
Top achievements
Rank 2
Dimitar Milushev
Telerik team
Timothy Robbins
Top achievements
Rank 1
Share this question
or