Completed
Last Updated: 04 Jul 2014 11:55 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 16 Apr 2014 14:11
Category: GridView
Type: Bug Report
0
FIX. RadGridView - GridNavigator.SelectLastRow method causes performance issue in load on demand hierarchy
To reproduce:
public Form1()
{
    InitializeComponent();

    for (int i = 0; i < 10; i++)
    {
        this.radGridView1.Columns.Add("Col" + i);
    }

    for (int i = 0; i < 8000; i++)
    {
        GridViewRowInfo row = radGridView1.Rows.NewRow();
        foreach (GridViewCellInfo cell in row.Cells)
        {
            cell.Value = "Data" + row.Index + "." + cell.ColumnInfo.Index;
        }
        radGridView1.Rows.Add(row);
    }
    GridViewTemplate childTemplate = CreateChildTemplate();
    this.radGridView1.Templates.Add(childTemplate);

    childTemplate.HierarchyDataProvider = new GridViewEventDataProvider(childTemplate);
    this.radGridView1.RowSourceNeeded += radGridView1_RowSourceNeeded;
}

private void radGridView1_RowSourceNeeded(object sender, GridViewRowSourceNeededEventArgs e)
{
    for (int i = 0; i < 10; i++)
    {
        GridViewRowInfo row = e.Template.Rows.NewRow();
        row.Cells["Name"].Value = "Name" + i;
        row.Cells["ProductNumber"].Value = "ProductNumber" + i;

        e.SourceCollection.Add(row);
    }
}

private GridViewTemplate CreateChildTemplate()
{
    GridViewTemplate template = new GridViewTemplate();
    template.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

    GridViewTextBoxColumn namecolumn = new GridViewTextBoxColumn("Name");
    GridViewTextBoxColumn productNumberColumn = new GridViewTextBoxColumn("ProductNumber");
    template.Columns.AddRange(namecolumn,
        productNumberColumn);

    return template;
}

private void radButton1_Click(object sender, EventArgs e)
{
     this.radGridView1.GridNavigator.SelectLastRow();
}

Workaround: navigate the vertical scrollbar to the last row before calling the SelectLastRow method:

private void radButton1_Click(object sender, EventArgs e)
{
    this.radGridView1.TableElement.RowScroller.Scrollbar.PerformLast();
    this.radGridView1.GridNavigator.SelectLastRow();
}
0 comments