Home - Forums-.NET - FlyTreeView (ASP.NET) - Populated nodes & NodeTypes

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Populated nodes & NodeTypes
Link Posted: 27-Feb-2007 10:42
Hi!

I am experiencing a minor frustration with an otherwise perfect component.

I am currently using the TreeView component to develop a \"file manager\" application. Each level of the file system is populated when needed using the OnPopulateNodes event.

As the default appearence i use the Windows XP template and on top of that i have two NodeTypes (one for folders and one for files) that ONLY changes the icon of the defaultStyle.

Now to the problem:
When the nodes get loaded they still have the default icon from the windows XP template. If i select the node nothing happends but when the node looses selection the icon is displayed correctly (from defaultStyle property of the NodeType). If i then select it again it reverts to windows xp icon and so on...

Any idea why this is? Or how i can fix it?

Here is the PopulateNodes method:
(I?ve removed some code for clarity)

protected void flyTreeView_PopulateNodes(object sender, NineRays.WebControls.FlyTreeNodeEventArgs e) {
    // Get all sub folders
    foreach (WebSite.FsFolders folder in folderTable) {
      // Create then node
      FlyTreeNode folderNode = new FlyTreeNode(folder.Name, folder.ID.ToString());
        folderNode.NodeTypeID = \"ntFolder\";

        // Does the folder have children?
        folderNode.PopulateNodesOnDemand = folderProvider.HasChildren(folder.ID);

        // Add the node
        e.Node.ChildNodes.Add(folderNode);
      }
    }
}


And this is the tree declaration:


              
                  
                  
                  










Thanks in advance
Bjorn Dahlin
Link Posted: 27-Feb-2007 19:50
Bjorn,

I took your code, changed ImageUrl of ntFolder nodetype to an image that I have (/test/img/classic_folder.png).

I also modified FileSystemNodes.cs (from examples application) so it creates nodes this way:

FlyTreeNode ftn = new FlyTreeNode();
ftn.Text = HttpUtility.HtmlEncode(subDir.Name);
ftn.Value = subDir.Name;
ftn.NodeTypeID = \"ntFolder\";
nodes.Add(ftn);

Now the treeview looks like this:



As you can see default node image is classic_folder.png (from ntFolder nodetype). The selected node uses $winxp_folder_open resource.
Everything looks like expected.
To change selected node image, I need just to change SelectedStyle.ImageUrl.


Also from my point of view, you can move ntFolder nodetype setting to the default treeview styles declaration:





So you will only need the only ntFile nodetype.