Grid Background Color

1. How do I set the background color of the rows in the grid?
2. I used the following style to change alternate row color:
.e-grid .e-altrow {
    background-color: aliceblue;

This changes the row color for every other row. But how do I change the color of the other rows?

Regards,
Amjad.

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team May 17, 2021 03:33 AM UTC

Hi Amjad,  
 
Thanks for contacting Syncfusion support.  
 
Query: “This changes the row color for every other row. But how do I change the color of the other rows? 
 
We have achieved your requirement by applying the below style to other rows using the specific class name. Refer the below code example.  
 
<style> 
    /*to style the alternate rows*/ 
    .e-grid .e-row.e-altrow { 
        background-coloraliceblue; 
    } 
    /*to style the remaining rows*/ 
    .e-grid .e-row { 
        background-colorantiquewhite; 
    } 
</style> 
 
 
Refer our UG documentatoin for your reference 
 
 
Note: If you want to change the background color of row based on the record value, we suggest you to achieve this requirement by adding a specific class name to that row using RowDataBound event of the Grid.   
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer

AK Amjad Khan May 18, 2021 03:34 PM UTC

Thank you so much.

I also tried this and this works as well:

tr:nth-child(even) {
    
    background-color: #cdd8fd;
}
tr:nth-child(odd) {
    
    background-color: #bdc1ff;
}



VN Vignesh Natarajan Syncfusion Team May 19, 2021 04:29 AM UTC

Hi Amjad,  

Thanks for the update.  

We are glad to hear that you have achieved your requirement.  

Kindly get back to us if you have further queries.  

Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon