Completed
Last Updated: 14 Mar 2016 09:52 by ADMIN
ADMIN
Hristo
Created on: 12 Jan 2016 15:23
Category: GridView
Type: Bug Report
0
FIX. RadGridView - when the cell editor of MCCB column is initialized for the first time in the new row, it is populated with value, while it should be empty
How to reproduce: the MCCB column needs to be set with  AutoCompleteMode.SuggestAppend
public partial class Form1 : Form
{
    private List<MyComboItem> listItems;

    public Form1()
    {
        InitializeComponent();

        this.listItems = new List<MyComboItem>();

        listItems.Add(new MyComboItem("Item1", "This is test for item1"));
        listItems.Add(new MyComboItem("Atn time", "This is test for item2"));

        listItems.Add(new MyComboItem("Bc chars", "This is test for item3"));
        listItems.Add(new MyComboItem("Elsa", "This is test for item4"));
        listItems.Add(new MyComboItem("Elementary", "This is test for item4"));
        GridViewMultiComboBoxColumn gridviewColumn1 = radGridView1.Columns[0] as GridViewMultiComboBoxColumn;
        if (gridviewColumn1 != null)
        {
            gridviewColumn1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
            gridviewColumn1.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDown;

            gridviewColumn1.DataSource = listItems;
        }
    }
}

public class MyComboItem
{
    public string Code { get; set; }
    public string Description { get; set; }
    public MyComboItem(string code, string description)
    {
        this.Code = code;
        this.Description = description;
    }
}

Workaround: handle the CellEditorInitialized and remove the selection 
private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
{
    if (radGridView1.CurrentColumn is GridViewMultiComboBoxColumn)
    {
        RadMultiColumnComboBoxElement editor = e.ActiveEditor as RadMultiColumnComboBoxElement;
        if (editor != null && e.Row is GridViewNewRowInfo)
        {
            editor.SelectedIndex = -1;
        }
    }
}
(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments