Completed
Last Updated: 15 Sep 2015 13:37 by ADMIN
ADMIN
Dess | Tech Support Engineer, Sr.
Created on: 03 Dec 2014 08:54
Category: GridView
Type: Bug Report
1
FIX. RadGridView - editor is activated for the wrong cell when resizing the grid while editing
To reproduce: use the following code snippet and perform the steps illustrated on the attached gif file.

radGridView1.Columns.Add(new GridViewTextBoxColumn("A", "A"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("B", "B"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("C", "C"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("D", "D"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("E", "E"));
radGridView1.Columns.Add(new GridViewTextBoxColumn("F", "F"));


radGridView1.Columns[0].Width = 150;
radGridView1.Columns[1].Width = 150;
radGridView1.Columns[2].Width = 150;
radGridView1.Columns[3].Width = 150;
radGridView1.Columns[4].Width = 150;
radGridView1.Columns[5].Width = 150;

radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");
radGridView1.Rows.Add("A", "B", "C", "D", "E", "F");

Workaround: 

private void radGridView1_Resize(object sender, EventArgs e)
{
    if (this.radGridView1.IsInEditMode)
    {
        this.radGridView1.EndEdit();
        this.radGridView1.BeginEdit();              
    }
}

public class CustomGrid : RadGridView
{
    public override string ThemeClassName  
    { 
        get 
        { 
            return typeof(RadGridView).FullName;  
        }
    }

    protected override RadGridViewElement CreateGridViewElement()
    {
        return new CustomRadGridViewElement();
    }
}

public class CustomRadGridViewElement : RadGridViewElement
{
    protected override Type ThemeEffectiveType     
    { 
        get    
        { 
            return typeof(RadGridViewElement);     
        }
    }

    protected override GridViewEditManager CreateEditorManager()
    {
        return new CustomGridViewEditManager(this);
    }
}

public class CustomGridViewEditManager : GridViewEditManager
{
    public CustomGridViewEditManager(RadGridViewElement gridViewElement) : base(gridViewElement)
    {
    }

    protected override void InitializeEditor(IInputEditor activeEditor)
    {
        if (activeEditor == null)
        {
            activeEditor = this.GridViewElement.CurrentColumn.GetDefaultEditor();
            this.ActiveEditor = activeEditor;
        }
        base.InitializeEditor(activeEditor);
    }
}
Attached Files:
1 comment
ADMIN
Ivan Petrov
Posted on: 12 Aug 2015 14:11
The correct behavior here would be to close the editor and this is what we will introduce as a fix for this case. Here is why:
1. Because of the RadGridView UI virtualization if you start resizing it, with an editor open, the cell containing the editor will be cached and then reused for another data cell. As a result, the editor will jump all over the visual cells of RadGridView. This will not be the case for grids with AutoSizeColumnsMode set to Fill and for such grids the editor will not be closed, not will it jump to other cells while resizing.
2. If the editor remains open and you resize the grid so the edited cell goes out of view, validation will be hard to convey to the users. If the edited cell is out of view and validation fails there is no clear way to indicate that to the user.