Completed
Last Updated: 06 Jun 2016 07:22 by ADMIN
ADMIN
Dess | Tech Support Engineer, Principal
Created on: 30 May 2016 09:16
Category: GridView
Type: Bug Report
2
FIX. RadGridView - NullReferenceException when clicking the new row positioned at the bottom and the AutoSizeRows property is set to true
WORKAROUND:
1. Create a custom GridTableElement and override the ProcessColumnEvent method.
2. Create a custom TableViewDefinition and override the CreateViewUIElement to return the custom table element.
3. Assign the custom view definition to the grid's ViewDefinition property

public class CustomGridTableElement : GridTableElement
{
    protected override GridViewEventResult ProcessColumnEvent(GridViewColumn column, GridViewEvent eventData)
    {
        if (eventData.Info.Id == KnownEvents.PropertyChanged)
        {
            RadPropertyChangedEventArgs args = eventData.Arguments[0] as RadPropertyChangedEventArgs;

            if (args.Property == GridViewColumn.IsVisibleProperty)
            {
                ViewElement.UpdateRowsWhenColumnsChanged();

                if (this.GridViewElement.AutoSizeRows)
                {
                    foreach (GridViewRowInfo row in this.ViewTemplate.Rows)
                    {
                        row.Height = -1;
                    }

                    this.UpdateLayout();
                    this.RowScroller.UpdateScrollRange();
                }

                return null;
            }
        }

        return base.ProcessColumnEvent(column, eventData);
    }

    protected override Type ThemeEffectiveType
    {
        get { return typeof(GridTableElement); }
    }
}


public class CustomTableViewDefinition : TableViewDefinition
{
    public override IRowView CreateViewUIElement(GridViewInfo viewInfo)
    {
        return new CustomGridTableElement();
    }
}


this.radGridView1.ViewDefinition = new CustomTableViewDefinition();

0 comments