This is a migrated thread and some comments may be shown as answers.

GridView column header groups

2 Answers 113 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Recep
Top achievements
Rank 1
Recep asked on 05 Sep 2012, 12:40 PM
After upgrading to new version (2012.2.725.1050) from (2012..507.1050) we started to get an exception in grids with column header groups. Here is the stack trace:

System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.RealizeHeadersAtRow(Int32 row, List`1 subHeaders)
at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.RealizeHeaders()
at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.PlaceCommonHeaders()
at Telerik.Windows.Controls.GridView.CommonHeaderPresenter.OnApplyTemplate()
at System.Windows.FrameworkElement.OnApplyTemplate(IntPtr nativeTarget)  

I checked the RealizeHeadersAtRow method with ILSpy and noticed that commonColumnHeader is only initialized under certain conditions. So, I guess that is the real cause of the null reference exception.

ILSpy output:
private List<CommonColumnHeader> RealizeHeadersAtRow(int row, List<CommonColumnHeader> subHeaders)
{
    GridViewColumnGroup gridViewColumnGroup = null;
    CommonColumnHeader commonColumnHeader = null;
    int num = 0;
    int num2 = 0;
    int columnCountToRealize = this.GetColumnCountToRealize(subHeaders);
    for (int i = 0; i < columnCountToRealize; i++)
    {
        string groupNameByIndex = this.GetGroupNameByIndex(subHeaders, i);
        GridViewColumnGroup gridViewColumnGroup2 = CommonHeaderPresenter.FindGroupByName(groupNameByIndex, this.ColumnGroups);
        if (gridViewColumnGroup != gridViewColumnGroup2 || string.IsNullOrEmpty(groupNameByIndex))
        {
            num = 0;
            gridViewColumnGroup = gridViewColumnGroup2;
            commonColumnHeader = this.RealizeHeaderForGroup(gridViewColumnGroup2, row, num2);
        }
        int subItemsSpan = CommonHeaderPresenter.GetSubItemsSpan(subHeaders, i);
        num += subItemsSpan;
        num2 += subItemsSpan;
        commonColumnHeader.SetValue(Grid.ColumnSpanProperty, num);
    }
    return Enumerable.ToList<CommonColumnHeader>(Enumerable.Where<CommonColumnHeader>(this.realizedHeaders, (CommonColumnHeader header) => header.RowIndex == row));
}

Is this something we can workaround? 

Please advise, 
Thanks.

2 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 06 Sep 2012, 12:37 PM
Hi ,

In our recent internal libs we have a fix included for similar exception . Please download our latest internal build and give it a try.

In case this does not help , please paste me the definition of your column groups and I will personally take care for a fix to be provided in the service pack ( expected soon) .

Please excuse us for the inconvenience caused !

Regards,
Pavel Pavlov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Recep
Top achievements
Rank 1
answered on 20 Sep 2012, 10:04 AM
That fixed the exception but we had styling issues with that version. So, we reverted back to a previous one (version 2012.2.607 from June 8) which resolved both issues.



Thanks.
Tags
GridView
Asked by
Recep
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Recep
Top achievements
Rank 1
Share this question
or