Completed
Last Updated: 28 Nov 2014 08:45 by ADMIN
ADMIN
George
Created on: 05 Nov 2014 11:33
Category: GridView
Type: Bug Report
0
FIX. RadGridView - if the row and column of the event arguments of the CellEndEdit event are null an exception is throw
To reproduce:

Download the attached project, run it and try to filter the bottom grid. You will see the exception

Workaround:

Use the following custom RadGridView:

public class MyGrid : RadGridView
{
    protected override RadGridViewElement CreateGridViewElement()
    {
        return new MyGridElement();
    }
}

public class MyGridElement : RadGridViewElement
{
    protected override MasterGridViewTemplate CreateTemplate()
    {
        return new MyMasterTemplate();
    }

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

public class MyMasterTemplate : MasterGridViewTemplate
{
    private MyEventDispatcher dispatcher = new MyEventDispatcher();

    public override EventDispatcher EventDispatcher
    {
        get
        {
            return this.dispatcher;
        }
    }
}

public class MyEventDispatcher : EventDispatcher
{
    public override void RaiseEvent<T>(object eventKey, object sender, T args)
    {
        GridViewCellEventArgs cellArgs = args as GridViewCellEventArgs;
        if (cellArgs != null && cellArgs.Column == null && cellArgs.Row == null)
        {
            typeof(GridViewCellEventArgsBase)
                .GetField("column", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
                .SetValue(cellArgs, new GridViewTextBoxColumn());

            typeof(GridViewCellEventArgsBase)
                .GetField("row", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic)
                .SetValue(cellArgs, new GridViewDataRowInfo(null));
        }

        base.RaiseEvent<T>(eventKey, sender, args);
    }
}
Attached Files:
0 comments