GridView column header groups

3 posts, 0 answers
  1. Recep
    Recep avatar
    4 posts
    Member since:
    Sep 2012

    Posted 05 Sep 2012 Link to this post

    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. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 06 Sep 2012 Link to this post

    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.

  3. Recep
    Recep avatar
    4 posts
    Member since:
    Sep 2012

    Posted 20 Sep 2012 Link to this post

    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.
Back to Top