Completed
Last Updated: 18 Nov 2014 06:47 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 14 Nov 2014 16:29
Category: GridView
Type: Bug Report
1
FIX. RadGridView - NullReferenceException when AllowSearchRow property is set to true and the grid is bound to self referencing data
To reproduce:

public Form1()
{
    InitializeComponent();

    DataTable dt = new DataTable();
    dt.Columns.Add("Id", typeof(int));
    dt.Columns.Add("ParentId", typeof(int));
    dt.Columns.Add("IsActive", typeof(bool));
    dt.Columns.Add("Title", typeof(string));

    for (int i = 1; i < 6; i++)
    {
        dt.Rows.Add(i, 0, i % 2 == 0, "Title" + i);
    }
    Random rand = new Random();
    int parentIndex = 0;
    for (int i = 6; i < 30; i++)
    {
        parentIndex = rand.Next(1, 6);
        dt.Rows.Add(i, parentIndex, i % 2 == 0, "Title" + i);
    }

    radGridView1.DataSource = dt;
    radGridView1.AutoSizeColumnsMode = Telerik.WinControls.UI.GridViewAutoSizeColumnsMode.Fill;
    radGridView1.Relations.AddSelfReference(radGridView1.MasterTemplate, "Id", "ParentId");

    GroupDescriptor descriptor = new GroupDescriptor();
    descriptor.GroupNames.Add("Title", System.ComponentModel.ListSortDirection.Ascending);
    radGridView1.GroupDescriptors.Add(descriptor);

    this.radGridView1.AllowSearchRow = true;
}
0 comments