null exception on GetSummaryDisplayTextForRow

I am getting the good old {"Object reference not set to an instance of an object."}

I attached the stack trace at the end of this message.

It started after I added summary row to the grouping

the grouping and the summary are working greate - but after few seconds to a minute I am getting the exception (even if the bound data is not changing)

Is there a way to debug it and figure out why it happens?or which row cause the problem?
Any other idea?

Thanks!!!

this.sfDataGrid1.GroupColumnDescriptions.Add(new GroupColumnDescription() { ColumnName = "Type" });


// Creates the GridSummaryRow.
GridSummaryRow captionSummaryRow = new GridSummaryRow();
captionSummaryRow.Name = "CaptionSummary";
captionSummaryRow.ShowSummaryInRow = false;
captionSummaryRow.TitleColumnCount = 1;
captionSummaryRow.Title = "{Key} ({ItemsCount})";


// Creates the GridSummaryColumn1.
GridSummaryColumn summaryColumn1 = new GridSummaryColumn();
summaryColumn1.Name = "TotalActualPower";
summaryColumn1.Format = "{Sum}";
summaryColumn1.MappingName = "ActualPower";
summaryColumn1.SummaryType = SummaryType.Int32Aggregate;


// Adds the summary column in the SummaryColumns collection.
captionSummaryRow.SummaryColumns.Add(summaryColumn1);


// Initializes the caption summary row.
this.sfDataGrid1.CaptionSummaryRow = captionSummaryRow;


this.sfDataGrid1.Style.CaptionSummaryRowStyle.BackColor = Color.LightSkyBlue;
this.sfDataGrid1.Style.CaptionSummaryRowStyle.Font = new GridFontInfo(new Font("Arial", 10f, FontStyle.Bold));

++++++++++++++++++++++++++++++++++++++++++++++++++++++++


at Syncfusion.Data.SummaryCreator.<>c__DisplayClass2.b__0(ISummaryColumn col)
at Syncfusion.Data.Extensions.FunctionalExtensions.ForEach[T](IEnumerable`1 items, Action`1 action)
at Syncfusion.Data.SummaryCreator.GetSummaryDisplayTextForRow(SummaryRecordEntry summaryEntry, ICollectionViewAdv collectionView, String columnHeaderName)
at Syncfusion.WinForms.DataGrid.GridPainter.GetCaptionSummaryCellValue(DataRowBase dataRow, GridColumn column)
at Syncfusion.WinForms.DataGrid.GridPainter.GetCellValue(DataRowBase dataRow, GridColumn column)
at Syncfusion.WinForms.DataGrid.GridPainter.DrawSpannedDataColumn(DataRowBase dataRow, DataColumnBase column, VisibleLineInfo line, Graphics graphics, Rectangle finalSize, Int32& width)
at Syncfusion.WinForms.DataGrid.GridPainter.DrawCaptionSummaryRow(DataRowBase dataRow, Rectangle finalSize, Graphics graphics, IEnumerable`1 visibleColumns)
at Syncfusion.WinForms.DataGrid.GridPainter.DrawCaptionSummaryRow(Graphics graphics, DataRowBase dataRow, Rectangle finalSize)
at Syncfusion.WinForms.DataGrid.GridPainter.DrawRow(DataRowBase dataRow, Rectangle finalSize, Graphics graphics)
at Syncfusion.WinForms.DataGrid.GridPainter.DrawRows(Graphics graphics)
at Syncfusion.WinForms.DataGrid.GridPainter.OnPaint(PaintEventArgs e, Size clientSize)
at Syncfusion.WinForms.DataGrid.TableControl.OnPaint(PaintEventArgs e)
at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
at System.Windows.Forms.Control.WmPaint(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.WinForms.Controls.SfScrollControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

1 Reply

VS Vijayarasan Sivanandham Syncfusion Team October 14, 2021 12:29 PM UTC

Hi Aya,

Thank you for contacting Syncfusion Support.

We have prepared the simple sample based on provided code snippet from our end. The reported issue “Null exception on GetSummaryDisplayTextForRow in SfDataGrid” and unable to replicate the issue from our end. It is working fine as expected. Please find the tested sample and video demo from our end in the link below,

Sample link: https://www.syncfusion.com/downloads/support/forum/169621/ze/Sample520953605
 
Video Link: https://www.syncfusion.com/downloads/support/forum/169621/ze/CaptionSummaryRowDisplayProperly-804926464

Please have a look at this sample and let us know if we have missed any customization done in your application. Otherwise try to reproduce the reported issue in this sample and revert to us with the modified sample and steps to replicate the issue. It will be more helpful for us to find the exact cause for the issue and to provide a prompt solution.

Regards,
Vijayarasan S
 


Loader.
Up arrow icon