Group can't be null

Hi,

when i try to add a group programmatically, I get the error - 'Group can't be null'

what could be the reason for this? Here's how i add grouping:

if (dgMain.GroupColumnDescriptions.Count != 0) { dgMain.GroupColumnDescriptions.Clear(); }
                dgMain.View.BeginInit();
                string[] GCols = gl.GroupByCols.Split(',');
                foreach (string s in GCols)
                {
                    dgMain.Columns.Add(Cols.Find(x => x.MappingName.Contains(s)));
                    GroupColumnDescription gp = new GroupColumnDescription();
                    gp.ColumnName = s;
                    this.dgMain.GroupColumnDescriptions.Add(gp);
                }
                dgMain.View.EndInit();

1 Reply 1 reply marked as answer

SJ Sathiyathanam Jeyakumar Syncfusion Team November 10, 2022 03:01 PM UTC

We are able to reproduce the reported exception with the provided code snippets and you can avoid the exception by commented out the View.BeginInit() and View.EndInit() codes while adding the group. And View.BeginInit() and View.EndInit() method is used to improve the performance while make the bulk data updates in SfDataGrid. Please provide the details for why you used the View.BeginInit() and View.EndInit() while adding the group? It will be helpful to investigate further regarding this.

if (dgMain.GroupColumnDescriptions.Count != 0)

{

    dgMain.GroupColumnDescriptions.Clear();

}

//dgMain.View.BeginInit();

string[] GCols = gl.GroupByCols.Split(',');

foreach (string s in GCols)

{

    dgMain.Columns.Add(Cols.Find(x => x.MappingName.Contains(s)));

    GroupColumnDescription gp = new GroupColumnDescription();

    gp.ColumnName = s;

    this.dgMain.GroupColumnDescriptions.Add(gp);

}

//dgMain.View.EndInit();


Marked as answer
Loader.
Up arrow icon