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

Self-Reference takes too long to expand a node

12 Answers 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andy
Top achievements
Rank 1
Andy asked on 07 Mar 2011, 07:55 PM
I have a grid with 5 columns, the first 2 columns, ID and ParentID, are for self-reference setup and are hidden. The rest are a checkbox and 2 text columns. I set its datasource to a BindingList that has a single row and 250 "child" rows. The parent row expands fine when there is no sorting. However, as soon as I click on any of the column headers to sort, it takes more than 10 seconds to expand, and scrolling also becomes very sluggish.
I'm using the latest release, RadControls_WinForms_2010_3_10_1215_dev. Is there a trick to speed it up? Below are the code snippet and attached is a scree

Thanks,
Andy
    private void Form1_Load(object sender, EventArgs e)
    {
        PopulateGrid();
        radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "ID", "ParentID");
    }
 
    private void PopulateGrid()
    {
        BindingList<RowBindingInfo> rowList = new BindingList<RowBindingInfo>();
        int rowID = -1;
 
        for (int i = 0; i < 1; i++)
        {
            RowBindingInfo rowInfo = new RowBindingInfo(++rowID, -1, false, "Room " + i.ToString(), "Desc " + i.ToString());
            rowList.Add(rowInfo);
 
            int pid = rowID;
            for (int j = 0; j < 250; j++)
            {
                RowBindingInfo childRow = new RowBindingInfo(++rowID, pid, false, string.Empty, "Desk " + j.ToString());
                rowList.Add(childRow);
            }
        }
 
        radGridView1.DataSource = rowList;
    }
}
 
public class RowBindingInfo
{
    public RowBindingInfo(int rid, int prid, bool incl, string r, string d)
    {
        ID = rid;
        ParentID = prid;
        Included = incl;
        Room = r;
        Desc = d;
    }
 
    public int ID { get; set; }
    public int ParentID { get; set; }
    public bool Included { get; set; }
    public string Room { get; set; }
    public string Desc { get; set; }
}


Thanks,
Andy

12 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 08 Mar 2011, 11:43 AM
Hello Andy,

I have tested your example and for me, with 250 it's loading instantly, and with 1000 it takes ~0.30 sec.
Please take a look at this revised example:
using System;
using System.ComponentModel;
using System.Windows.Forms;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    private RadGridView radGridView1;
    private DateTime startTime;
    private DateTime endTime;
 
    public Form1()
    {
        InitializeComponent();
        this.Controls.Add(radGridView1 = new RadGridView());
        radGridView1.Dock = DockStyle.Fill;
        radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
        radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "ID", "ParentID");
        radGridView1.ChildViewExpanding += new ChildViewExpandingEventHandler(radGridView1_ChildViewExpanding);
        radGridView1.ChildViewExpanded += new ChildViewExpandedEventHandler(radGridView1_ChildViewExpanded);
    }
 
    void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
    {
        endTime = DateTime.Now;
        MessageBox.Show((endTime - startTime).ToString());
    }
 
    void radGridView1_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
    {
        startTime = DateTime.Now;
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        PopulateGrid();
    }
 
    private void PopulateGrid()
    {
        BindingList<RowBindingInfo> rowList = new BindingList<RowBindingInfo>();
 
        int rowID = -1;
 
        for (int i = 0; i < 1; i++)
        {
            RowBindingInfo rowInfo = new RowBindingInfo(++rowID, -1, false, "Room " + i.ToString(), "Desc " + i.ToString());
            rowList.Add(rowInfo);
 
            int pid = rowID;
            for (int j = 0; j < 1000; j++)
            {
                RowBindingInfo childRow = new RowBindingInfo(++rowID, pid, false, string.Empty, "Desk " + j.ToString());
                rowList.Add(childRow);
            }
        }
 
        radGridView1.DataSource = rowList;
    }
}
 
public class RowBindingInfo
{
    public RowBindingInfo(int rid, int prid, bool incl, string r, string d)
    {
        ID = rid;
        ParentID = prid;
        Included = incl;
        Room = r;
        Desc = d;
    }
 
    public int ID { get; set; }
 
    public int ParentID { get; set; }
 
    public bool Included { get; set; }
 
    public string Room { get; set; }
 
    public string Desc { get; set; }
}

Please let me know how this turns out

Hope this helps, if you have any other questions or comments, please let me know,

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 08 Mar 2011, 12:00 PM
Hi Guys,

Andy, I can replicate your issue, including with the sample that Emanuel has provided. The problem occurs after sorting. (I've attached a screenshot). I believe that this is the same issue as the one in this recent forum post.

The new Q1 2011 release is out soon, and as soon as I can try it with that, I can let you know if it is fixed in that release. In the meantime, i'd suggest looking over that forum post for suggested workaround.
Regards,
Richard
0
Emanuel Varga
Top achievements
Rank 1
answered on 08 Mar 2011, 12:16 PM
Hello guys,

Andy please try to provide all the necessary details to reproduce this;

A very basic example on a workaround would be:
using System;
using System.ComponentModel;
using System.Linq;
using System.Windows.Forms;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
 
public partial class Form1 : Form
{
    private RadGridView radGridView1;
    private DateTime startTime;
    private SortDescriptor[] sortDescriptors;
    private DateTime endTime;
 
    public Form1()
    {
        InitializeComponent();
        this.Controls.Add(radGridView1 = new RadGridView());
        radGridView1.Dock = DockStyle.Fill;
        radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
 
        radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "ID", "ParentID");
        radGridView1.ChildViewExpanding += new ChildViewExpandingEventHandler(radGridView1_ChildViewExpanding);
        radGridView1.ChildViewExpanded += new ChildViewExpandedEventHandler(radGridView1_ChildViewExpanded);
    }
 
    void radGridView1_ChildViewExpanded(object sender, ChildViewExpandedEventArgs e)
    {
        endTime = DateTime.Now;
        if (sortDescriptors != null && sortDescriptors.Length != 0)
        {
            radGridView1.SortDescriptors.AddRange(sortDescriptors);
            sortDescriptors = null;
        }
 
        MessageBox.Show((endTime - startTime).ToString());
    }
 
    void radGridView1_ChildViewExpanding(object sender, ChildViewExpandingEventArgs e)
    {
        startTime = DateTime.Now;
        if (radGridView1.SortDescriptors.Count != 0)
        {
            sortDescriptors = radGridView1.SortDescriptors.ToArray();
        }
 
        radGridView1.SortDescriptors.Clear();
    }
 
    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
 
        PopulateGrid();
    }
 
    private void PopulateGrid()
    {
        BindingList<RowBindingInfo> rowList = new BindingList<RowBindingInfo>();
 
        int rowID = -1;
 
        for (int i = 0; i < 1; i++)
        {
            RowBindingInfo rowInfo = new RowBindingInfo(++rowID, -1, false, "Room " + i.ToString(), "Desc " + i.ToString());
            rowList.Add(rowInfo);
 
            int pid = rowID;
            for (int j = 0; j < 1000; j++)
            {
                RowBindingInfo childRow = new RowBindingInfo(++rowID, pid, false, string.Empty, "Desk " + j.ToString());
                rowList.Add(childRow);
            }
        }
 
        radGridView1.DataSource = rowList;
    }
}
 
public class RowBindingInfo
{
    public RowBindingInfo(int rid, int prid, bool incl, string r, string d)
    {
        ID = rid;
        ParentID = prid;
        Included = incl;
        Room = r;
        Desc = d;
    }
 
    public int ID { get; set; }
 
    public int ParentID { get; set; }
 
    public bool Included { get; set; }
 
    public string Room { get; set; }
 
    public string Desc { get; set; }
}

Hope this helps, if you have any other questions or comments, please let me know,

(((@offtopic, Richard, do you still have that email address?)))

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 08 Mar 2011, 12:26 PM
Hi again,

Yes, your workaround does seem to help a lot Emanuel, though after a second expand/collapse, and re-sort it is still slower than I believe it should be at the moment (though much faster than it was).

@Andy - I'd agree with Emanuel's workaround for this situation too, but if I can find one that's faster, I'll let you know. In the meantime if you have any questions or comments, please let me know.

Regards,
Richard

----------------------------------------
offtopic - @Emanuel, yes, email still the same, and I'm sure I have yours too...
Richard..
0
Andy
Top achievements
Rank 1
answered on 08 Mar 2011, 06:59 PM
Hi guys, thank you both for your and suggestions.

@Emanuel, I ran your latest example and it took between 4 and 5 seconds to expand after sorting, which is much faster than mine, but still has a noticeable delay. And once the node is expanded, scrolling is terribly slow. I can replicate it using your example on several machines running Windows XP with Duo Core 2.66GHz CPU and 2G of RAM.

Please let me know if you come up with a different optimization, or if this issue has been addressed in the upcoming release. I'm also open to alternatives.

Thanks,
Andy

0
Andy
Top achievements
Rank 1
answered on 10 Mar 2011, 12:22 AM
Hi again Emanuel and Richard, have you been able to duplicate the app hanging when you try to scroll or re-size the form while the node is expanded? It takes a very long time for the form to be responsive again. Our product is close to finalizing and this issue is a major show-stopper.

Thanks,
Andy
0
Emanuel Varga
Top achievements
Rank 1
answered on 10 Mar 2011, 08:41 AM
Hello Andy,

Yes, i can reproduce this issue but this only happens if a sort operation is performed.

You should really open a support ticket on this one.

Best Regards,
Emanuel Varga
Telerik WinForms MVP
0
Richard Slade
Top achievements
Rank 2
answered on 10 Mar 2011, 10:15 AM
Hi Andy, 

To add to Emanuel's comments, when you open a support ticket, it would be useful to include this forum thread as a link in order to show the trail of what has been discussed already. 
Thanks
Richard
0
Alexander
Telerik team
answered on 10 Mar 2011, 12:36 PM
Hello Andy,

I confirm that the sorting of RadGridView slows down its performance when the control is used in self-reference hierarchy mode. Thank you for reporting it. I have updated your Telerik points. I added the issue to our PITS.

We will investigate this case and will try to improve the performance of the control in a future version. The Q1 2011 release data is pretty close and most probably the issue will be addressed in a later release.

Best regards,
Alexander
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Richard Slade
Top achievements
Rank 2
answered on 10 Mar 2011, 12:41 PM
Hi Alexander,

Please also see this forum post which looks like it may be the same issue, but not in Self-Reference hierarchy mode.
Hope that helps
Richard
0
Andy
Top achievements
Rank 1
answered on 15 Mar 2011, 02:31 AM
I have submitted a support ticket for this issue. The ticket number is 403283 in case you need to know.

I desperately need a fix for this problem...

Andy
0
Alexander
Telerik team
answered on 15 Mar 2011, 03:20 PM
Hello Andy,

As I explained in my previous answer, this is an issue in the RadGridView self-reference mechanism. Unfortunately, I am not able to provide you with a suitable workaround. We will try to optimize the control performance in this scenario in a future release after Q1 2011.

Best regards,
Alexander
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
GridView
Asked by
Andy
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Richard Slade
Top achievements
Rank 2
Andy
Top achievements
Rank 1
Alexander
Telerik team
Share this question
or