Is there a way to customize the style for all the columns in the grid at once ?

From what I understood, based on  the info contained in this link here , to change the grid columns style,  each one in the grid must be individually customized via a CustomAttributtes. That is a great functionality, but what if I want all columns to have the same style ? Is there a way to do it or should the same CustomAttributtes be applied to each one of the columns in the grid  ?  

e-attr{
        background: #5DADE2;
        font-family: "Bell MT";
        color: red;
        font-size: 5px;
    }
    <GridColumns>
        <GridColumn Field=@nameof(Order.OrderID) ></GridColumn>
        <GridColumn Field=@nameof(Order.CustomerID) </GridColumn>
        <GridColumn Field=@nameof(Order.OrderDate) CustomAttributes="@(new Dictionary<string, object>(){ { "class", "e-attr" }})"></GridColumn>
        <GridColumn Field=@nameof(Order.Freight)></GridColumn>
    </GridColumns>


3 Replies 1 reply marked as answer

RN Rahul Narayanasamy Syncfusion Team November 4, 2020 12:33 PM UTC

Hi Ben, 

Greetings from Syncfusion. 

Query: Is there a way to customize the style for all the columns in the grid at once ? 

We have validated your query and you want to customize the style for all the columns/rows in the grid. You can achieve your requirement by using below CSS. Here, we have applied the customized styles to all the rows. Find the below code snippets and sample for your reference. 

 
<SfGrid DataSource="@Orders" AllowPaging="true" Height="200" @ref="Grid"> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        . . . 
    </GridColumns> 
</SfGrid> 
<style> 
 
    .e-grid .e-rowcell { 
        background: #5DADE2; 
        font-family: "Bell MT"; 
        color: red; 
        font-size: 15px; 
    } 
</style> 




Please let us know if you have any concerns. 

Regards, 
Rahul 


Marked as answer

BJ Ben Junior November 4, 2020 10:13 PM UTC

thanks 



RN Rahul Narayanasamy Syncfusion Team November 5, 2020 04:05 AM UTC

Hi Ben, 

Thanks for the update. 

Please get back to us if you need further assistance. 

Regards, 
Rahul 


Loader.
Up arrow icon