telerik/winforms-docs

Unclear Behaviour of AutoGenerateHierarchy

ChristopherGuay opened this issue · 1 comments

It should be made clear that the AutoGenerateHierarchy only traverses the top most child (recursively) to build the hierarchy.
This behaviour not being clear can make it very difficult to debug why the hierarchy only works up to a certain point.

Eg.

    1. A
    1. B
  •    3. C
    
  • 4. B
    
  •    5. C
    
  •        6. D
    
  •            7. E
    

In this case node 6 would not appear expandable, leaving node 7 hidden.
The C object in node 3 would be parsed to find C's contain a list of D's but the D object in node 6 is never parsed to find its list of E objects.

(I'm not sure exactly why GitHub comment formatting does not like the bullet list)

Hello, Christopher,
I have tested automatic hierarchy generation in RadGridView and it seems to work as expected even for 20 levels in depth. This is the sample code I have:

            this.radGridView1.AutoGenerateHierarchy = true; 

           List<Item> gridItems = new List<Item>();
           for (int i = 0; i < 1; i++)
           {
               gridItems.Add(new Item(i, "Item" + i, GetSubItems(1)));
           }
           this.radGridView1.DataSource = gridItems;
           

       private List<Item> GetSubItems(int level)
       {
           if (level>20)
           {
               return new List<Item>();
           }
           List<Item> nestedItems = new List<Item>();
           for (int i = 0; i < 1; i++)
           {
               nestedItems.Add(new Item(i, "Item" + level + "." + i, GetSubItems(level + 1)));
           }
           return nestedItems;
       }

       public class Item
       {
           public Item(int id, string name, List<Item> childItems)
           {
               Id = id;
               Name = name;
               Items = childItems;
           }

           public int Id { get; set; }
           public string Name { get; set; }
           public List<Item> Items   { get; set; } 
       }

I believe that the exact DataSource setup and its internal structure are important for the exact case. That is why I would kindly ask you to submit a support ticket from your Telerik account with further details about the specific scenario. Thus, we would be able to make an adequate analysis of the precise case and provide further assistance. Thank you in advance.