Filter row drop down styling

Hi,

is it possible somehow style filter row drop down? I need to change foreground and background colors there.


Thanks!

Ondřej Svoboda


3 Replies

MA Mohanram Anbukkarasu Syncfusion Team June 30, 2021 01:51 PM UTC

Hi Ondřej Svoboda, 

Thanks for contacting Syncfusion support.  

You can achieve your requirement to change the background and foreground color of the filter row dropdown by creating custom GridFilterRowCell as shown in the following code example.  

Code example :  

public MainWindow() 
{ 
    InitializeComponent(); 
    this.dataGrid.RowGenerator = new CustomRowGenerator(this.dataGrid); 
} 
 
 
public class GridFilterRowCellExt : GridFilterRowCell 
{ 
 
    public GridFilterRowCellExt() 
        : base() 
    { } 
 
    /// <summary> 
    /// Opens the FilterOptionPopup with the FilterOptionList. 
    /// </summary> 
 
    public override void OpenFilterOptionPopup() 
    { 
        base.OpenFilterOptionPopup(); 
 
        var styleListBox = new Style(typeof(ListBox)); 
 
        styleListBox.Setters.Add(new Setter 
        { 
            Property = BackgroundProperty, 
            Value = Brushes.SkyBlue 
        }); 
 
        styleListBox.Setters.Add(new Setter 
        { 
            Property = ForegroundProperty, 
            Value = Brushes.Blue 
        }); 
 
        this.FilterOptionsList.Style = styleListBox; 
         
    } 
} 
 
public class CustomRowGenerator : RowGenerator 
{ 
    public CustomRowGenerator(SfDataGrid dataGrid) 
        : base(dataGrid) 
    { 
    } 
 
    /// <summary> 
    /// Return the Custom FilterRowCell 
    /// </summary> 
    /// <typeparam name="T"></typeparam> 
    /// <returns>GridCell</returns> 
 
    protected override GridCell GetGridCell<T>() 
    { 
 
        //If the Cell is FilterRowCell return custom FilterRowCell 
 
        if (typeof(T) == typeof(GridFilterRowCell)) 
            return new GridFilterRowCellExt(); 
        return base.GetGridCell<GridCell>(); 
    } 
} 



Please let us know if you require any other assistance from us.  

Regards, 
Mohanram A. 




OS Ondrej Svoboda July 1, 2021 11:05 AM UTC

Works OK, thanks.



MA Mohanram Anbukkarasu Syncfusion Team July 1, 2021 03:21 PM UTC

Hi Ondřej Svoboda, 

Thanks for the update.  

We are glad to know that the provided solution worked at your end. Please let us know if you require any other assistance from us. We are happy to help you.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon