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

RadTreeGrid View Issue

1 Answer 10 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Karthik Kantharaj
Top achievements
Rank 1
Karthik Kantharaj asked on 05 Oct 2012, 01:13 PM
Hi Guys,

I am facing one strange issue , my client requirement please let me know this is possible or not

in tree grid below one sample

A - Node
   A1 Subnode of A
       A1  Items
       A1  items
   A items 1
   A items 2
  A2 Subnode of A
       A2 items
In the above example
A has A1 and A2 subnode
A has two items

If a folder(A) has subfolders… the items associated with the folder(A) show up BELOW the subfolder

My client need tree like below

A - Node
   A items 1
   A items 2
   A1 Subnode of A
       A1  Items
       A1  items
  A2 Subnode of A
       A2 items

means all items of A should come below A node and all sub node should come next to A node items
Is this possible?

Karthik.K

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 10 Oct 2012, 11:16 AM
Hi Karthik,

To achieve the requested functionality, you just need to add the Files before the Folders. For example in the following demo:
http://demos.telerik.com/aspnet-ajax/treeview/examples/applicationscenarios/directorystructure/defaultcs.aspx

You should modify the method as shown below:
private void BindTreeToDirectory(string virtualPath, RadTreeNode parentNode)
{
    string physicalPath = Server.MapPath(virtualPath);
 
    string[] files = Directory.GetFiles(physicalPath);
    foreach (string file in files)
    {
        RadTreeNode node = new RadTreeNode(Path.GetFileName(file));
        string extension = Path.GetExtension(file).ToLower().TrimStart('.');
 
        if (Array.IndexOf(KnownExtensions, extension) > -1)
        {
            node.ImageUrl = "~/TreeView/Img/Vista/" + extension + ".png";
        }
        else
        {
            node.ImageUrl = "~/TreeView/Img/Vista/unknown.png";
        }
 
        parentNode.Nodes.Add(node);
    }
 
    string[] directories = Directory.GetDirectories(physicalPath);
    foreach (string directory in directories)
    {
        RadTreeNode node = new RadTreeNode(Path.GetFileName(directory));
        node.Value = virtualPath + "/" + Path.GetFileName(directory);
        node.ImageUrl = "~/TreeView/Img/Vista/folder.png";
        node.ExpandMode = TreeNodeExpandMode.ServerSide;
        parentNode.Nodes.Add(node);
    }
}

I hope this will prove helpful.

Greetings,
Eyup
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.
Tags
Grid
Asked by
Karthik Kantharaj
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or