RadGridViewComboboxColumn filter

2 posts, 0 answers
  1. Szymon
    Szymon avatar
    6 posts
    Member since:
    Sep 2013

    Posted 01 Oct 2013 Link to this post

    is there any option to set filter to the cell not the whole column? I have table with two columns: Name, and refName. Name is typical textbox, and refName is combobox. I would like to have in my refName comboboxes all Names from first column except the one from the same row, eg.
    Name refName
    Name1 1
    Name2 2
    Name3 3

    where 1 should contain Name2 and Name3; 2: Name1 and Name3; 3: Name1 and Name2.
    I would also like to specify more filters in the future but for now this is all I need. :)

    How can I achieve my goal?

    Thanks in advance,
  2. Dess | Tech Support Engineer, Sr.
    Dess | Tech Support Engineer, Sr.  avatar
    4072 posts

    Posted 04 Oct 2013 Link to this post

    Hello Szymon,

    Thank you for contacting Telerik Support.

    In order to achieve your goal, please, have a look at the following approach:
    List<string> names = new List<string>();
    public Form1()
        List<MyName> objects = new List<MyName>()
            new MyName("John Smith"),
            new MyName("Peter Jackson"),
            new MyName("Merry Stones"),
            new MyName("Bryan Cold"),
        this.radGridView1.AutoGenerateColumns = false;
        GridViewTextBoxColumn textBoxColumn = new GridViewTextBoxColumn("Name");
        GridViewComboBoxColumn comboCol = new GridViewComboBoxColumn("Ref Name");
        comboCol.DataSource = names;
        this.radGridView1.DataSource = objects;
        this.radGridView1.CellEditorInitialized += radGridView1_CellEditorInitialized;
    private void radGridView1_CellEditorInitialized(object sender, GridViewCellEventArgs e)
        RadDropDownListEditor editor = e.ActiveEditor as RadDropDownListEditor;
        if (e.RowIndex > -1 && editor != null)
            editor.DropDownStyle = Telerik.WinControls.RadDropDownStyle.DropDownList;
            (editor.EditorElement as RadDropDownListEditorElement).DataSource =
                FilterList((editor.EditorElement as RadDropDownListEditorElement).DataSource, (e.Row.DataBoundItem as MyName).Name);
    private object FilterList(object dataSource, string filterName)
        List<string> dataNames = new List<string>();
        foreach (string name in dataSource as List<string>)
            if (name != filterName)
        return dataNames;
    private void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
        if (e.RowIndex > -1 && e.Column.Name == "Ref Name")
            (e.CellElement as GridComboBoxCellElement).Text = (e.Row.DataBoundItem as MyName).Name;
    private IEnumerable<string> GetNames(List<MyName> objects)
        List<string> objectNames = new List<string>();
        foreach (MyName nameObj in objects)
        return objectNames;
    public class MyName
        public string Name { get; set; }
        public MyName(string name)
            this.Name = name;

    I hope this information helps. Should you have further questions, I would be glad to help.

    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top