Search code examples
c#devexpressdevexpress-windows-ui

Change column editor type without changing filter editor type in GridControl


I have the following GridColumn defined:

new GridColumn{
    Visible = true,
    FieldName = "blah",
    Name = "blah",
    ColumnEdit = new RepositoryItemGridLookUpEdit{
        DisplayMember = "Name",
        ValueMember = "Id",
        DataSource = ViewModel.Components
    }
}

This works fine and changes the editor of my blah column to a the correct editor, but it also has an unwanted side-effect of changing the AutoFilterRow editor for that column to that same GridLookUpEdit. I want the filter to be just a regular text edit field. How can I achieve this?


Solution

  • You need to set GridColumn.FilterMode property to ColumnFilterMode.DisplayText value, it will allow filter values in your column by its DisplayText, so the field editor in AutoFilterRow will be changed to regular text editor:

    new GridColumn {
        Visible = true,
        FieldName = "blah",
        Name = "blah",
        FilterMode = ColumnFilterMode.DisplayText, //<= filter mode
        ColumnEdit = new RepositoryItemGridLookUpEdit{
            DisplayMember = "Name",
            ValueMember = "Id",
            DataSource = ViewModel.Components
        }
    }