This is about the following method:
public void SetError(GridViewCellCancelEventArgs e, Exception exception)
{
GridViewDataErrorEventArgs args = new GridViewDataErrorEventArgs(exception, 0, 0, GridViewDataErrorContexts.Commit);
if (e != null)
{
args = new GridViewDataErrorEventArgs(exception, e.ColumnIndex, e.RowIndex, GridViewDataErrorContexts.Commit);
}
this.EventDispatcher.RaiseEvent<GridViewDataErrorEventArgs>(EventDispatcher.DataError, this, args);
if (args.ThrowException)
{
throw args.Exception;
}
if (args.Cancel)
{
//TODO: cancel row edit
}
}
Right now, the method GridViewTemplate.SetError accepts a parameter of type GridViewCellCancelEventArgs, which in itself is weird, because event args should only be used inside events and OnXXX-methods. But since SetError fires an event, one could argue that this method is like a OnXXX-method.
But inside it becomes more weird, it translates GridViewCellCancelEventArgs into GridViewDataErrorEventArgs. And I must admit, the last DataError-args feel a lot more logical that CellCancel-args when firing setting an error. Furthermore, if I create an override of class GridViewCellCancelEventArgs to contain more data about an error, this information never reaches the event handlers.
So why this translation? Or better: Why this parameter?
My suggestion would be to make a new overload:
public void SetError(GridViewDataErrorEventArgs e)
{
if (e == null)
throw new ArgumentNullException(nameof(e));
this.EventDispatcher.RaiseEvent<GridViewDataErrorEventArgs>(EventDispatcher.DataError, this, args);
if (args.ThrowException)
throw args.Exception;
if (args.Cancel)
{
// TODO: I really do not know what telerik wanted to do here, so I live this up to Telerik.
}
}