Completed
Last Updated: 29 Oct 2015 08:45 by ADMIN
ADMIN
Hristo
Created on: 01 Apr 2015 14:56
Category: GridView
Type: Bug Report
0
FIX. RadGridView - scrolling with page down and page up slows down after a certain time when a lot of rows are added (15000)
How to reproduce: just create a grid with a great number of rows e.g. 15000 and scroll down using the page down key

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

        BaseGridBehavior gridBehavior = radGridView1.GridBehavior as BaseGridBehavior;
        gridBehavior.UnregisterBehavior(typeof(GridViewDataRowInfo));
        gridBehavior.RegisterBehavior(typeof(GridViewDataRowInfo), new CustomGridDataRowBehavior());

        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("Id", typeof(int));
        dataTable.Columns.Add("Name", typeof(string));
        dataTable.Columns.Add("IsValid", typeof(bool));

        for (int i = 0; i < 14000; i++)
        {
            dataTable.Rows.Add(i, "Name " + i, i % 2 == 0 ? true : false);
        }

        this.radGridView1.DataSource = dataTable;
        this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
    }
}

public class CustomGridDataRowBehavior : GridDataRowBehavior
{
    protected override bool ProcessPageUpKey(KeyEventArgs keys)
    {
        GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView;
        int index = this.GridViewElement.CurrentRow.Index - tableElement.RowsPerPage + 1;
        if (index < 0)
        {
            index = 0;
        }

        GridViewRowInfo firstScrollableRow = this.GridControl.Rows[index];
        this.GridViewElement.CurrentRow = firstScrollableRow;

        return true;
    }

    protected override bool ProcessPageDownKey(KeyEventArgs keys)
    {
        GridTableElement tableElement = (GridTableElement)this.GridViewElement.CurrentView;
        int index = this.GridViewElement.CurrentRow.Index + tableElement.RowsPerPage - 1;
        if (index > this.GridControl.Rows.Count - 1)
        {
            index = this.GridControl.Rows.Count - 1;
        }

        GridViewRowInfo lastScrollableRow = this.GridControl.Rows[index];
        this.GridViewElement.CurrentRow = lastScrollableRow;

        return true;
    }
}



0 comments