Unplanned
Last Updated: 14 May 2019 06:18 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 28 Mar 2014 10:53
Category: GridView
Type: Bug Report
4
FIX. RadGridView - performance issue in Object Relational Hierarchy Mode
To reproduce:
Add a RadGridView and use the following code. When you expand the first row, the vertical scrollbar is not correct. Scrolling down changes its size. However, if you expand the last row, it takes few seconds to open.

Second scenario:
In addition of the following code, if you change the TableElement.PageViewMode to PageViewMode.ExplorerBar, expanding the first row takes few seconds to load the hierarchical data as well.

public partial class Form1 : Form
{
    public Form1()
    {
        InitializeComponent();

        List<Item> items = new List<Item>();
        List<SubItem> subItems = new List<SubItem>();

        for (int i = 1; i <= 3; i++)
        {
            Item item = new Item(i, "Item" + i);
            
            for (int j = 1000; j <= 2010; j++)
            {
                subItems.Add(new SubItem(j, "SubItem" + j, i));
            }

            items.Add(item);
        }

        this.radGridView1.DataSource = items;
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

        GridViewTemplate template = new GridViewTemplate();
        template.ReadOnly = true;
        template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

        GridViewRelation relation = new GridViewRelation(this.radGridView1.MasterTemplate, template);
        relation.ParentColumnNames.Add("Id");
        relation.ChildColumnNames.Add("ItemId");
        this.radGridView1.MasterTemplate.Templates.Add(template);
        this.radGridView1.Relations.Add(relation);
        template.DataSource = subItems;
    }
}

public class Item
{
    public int Id { get; set; }

    public string Title { get; set; }

    public Item(int id, string title)
    {
        this.Id = id;
        this.Title = title;
    }
}

public class SubItem
{
    public int Id { get; set; }

    public int ItemId { get; set; }

    public string Name { get; set; }
    
    public SubItem(int id, string name, int itemId)
    {
        this.Id = id;
        this.ItemId = itemId;
        this.Name = name;
    }
}
1 comment
ADMIN
Hristo
Posted on: 14 May 2019 06:18
Hello,

The issue is inside the measure and arrange logic of the child templates. When setup in hierarchy the grid will create all of its child rows when a particular hierarchy template gets expanded. With thousands of child records this will impact the performance. The recommended solution for this scenario is to use the scrollbars inside the child templates: 
this.radGridView1.UseScrollbarsInHierarchy = true;

Setting the property to true will force the detail row to use fixed height when measuring and this way not all of the rows will be created.

Regards,
Hristo