Completed
Last Updated: 08 Jun 2015 13:16 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 27 Apr 2015 10:03
Category: GridView
Type: Bug Report
1
FIX. RadGridView - DataGroup.Expand method does not expand the group when Self-referencing hierarchy is used
To reproduce:

BindingList<Item> items = new BindingList<Item>();

public Form1()
{
    InitializeComponent();

    Item dataItem1 = new Item(1);
    dataItem1.Name = "Cat";
    dataItem1.GroupName = "Animal";
    dataItem1.GroupSortPriority = 2;
    items.Add(dataItem1);
    Item dataItem2 = new Item(2);
    dataItem2.Name = "Kitten";
    dataItem2.GroupName = "Animal";
    dataItem2.GroupSortPriority = 2;
    dataItem2.ParentIndex = 1;
    items.Add(dataItem2);
    Item dataItem3 = new Item(3);
    dataItem3.Name = "Trout";
    dataItem3.GroupName = "Fish";
    dataItem3.GroupSortPriority = 1;
    items.Add(dataItem3);
    radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "Index", "ParentIndex");
    radGridView1.DataSource = items;
}

private void ExpandSomeGroups()
{
    foreach (DataGroup group in radGridView1.Groups)
    {
        if (group.GroupRow.HeaderText.Contains("Animal"))
        {
            if (group.IsExpanded)
            {
                group.Collapse(false);
            }
            else
            {
                group.Expand(true);
            }
        }
    }
}

public class Item
{
    public Item(int index)
    {
        Index = index;
    }

    public int Index { get; private set; }

    public int ParentIndex { get; set; }

    public string Name { get; set; }

    public string GroupName { get; set; }

    public int GroupSortPriority { get; set; }
}



private void Form1_Load(object sender, EventArgs e)
{ 
    GroupDescriptor descriptor = new GroupDescriptor();
    descriptor.GroupNames.Add("GroupName", ListSortDirection.Ascending);
    radGridView1.GroupDescriptors.Add(descriptor);

    ExpandSomeGroups();
}

You will notice that the "Animal" group is not expanded. However, if you remove the self-referencing hierarchy, the "Animal" group will be expanded.
0 comments