We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Styling Group Header

I would like to display different color for different level of grouping.

1 Reply

SA Saravanan Ayyanar Syncfusion Team January 6, 2020 01:14 PM UTC

Hi Mariusz Juszkiewicz, 
 
Thank you for using Syncfusion control. 
 
You can achieve your requirement to display the different color for different level of grouping by using the sfDataGrid.QueryRowStyle event. Please refer the below code snippet, 
 
this.sfDataGrid.QueryRowStyle += SfDataGrid_QueryRowStyle; 
 
private void SfDataGrid_QueryRowStyle(object sender, QueryRowStyleEventArgs e) 
{ 
    if (e.RowType == RowType.CaptionRow || e.RowType == RowType.CaptionCoveredRow) 
    { 
        var groupLevel = (e.RowData as Group).Level; 
        if (groupLevel == 1) 
            e.Style.BackColor = Color.Red; 
        else if (groupLevel == 2) 
            e.Style.BackColor = Color.Bisque; 
        else if (groupLevel == 3) 
            e.Style.BackColor = Color.Blue; 
        else if (groupLevel == 4) 
            e.Style.BackColor = Color.Yellow; 
    } 
} 
 
 
Sample Link: 
 
Please let us know, if you require further assistance on this.   
   
Regards,   
Saravanan A. 


Loader.
Live Chat Icon For mobile
Up arrow icon