Implicit Style for CellStyle

Hi how can I set a Implicit Style for all GridTextColumn. e.g I want set Foreground Red and the Fontsize to 30 for all GridTextColumn in a ResourceDictionary for the entire  App without set it for each cell.


               
             

but it didn't work

5 Replies

AN Ashok N Syncfusion Team November 27, 2017 12:19 PM UTC

Hi Swo, 
 
Thanks for contacting Syncfusion support. 
 
You can achieve your requirement by using GridCell property. Already we have KB regarding this, please check the below KB link to get more details about this. 
 
Regards, 
Ashok 



SW swo November 28, 2017 07:38 PM UTC

Thanks for your answer.

After reading the

KB link: https://www.syncfusion.com/kb/6061/how-to-customize-the-foreground-color-for-cells-in-a-column-based-on-the-cell-content  


I still do not know how I can set a style for only once and not for each cell. In your example you set the style for the StudentMarks column in lines 8 to 12, how can i use the same style for all other colums (StudentId,StudentName ..) or in an other Datagrid without repaeat the style for each column? , I know this example  including a Value Converter makes no sence, but to set the Font and / or fontsize for all sfDataGridds in the whole Application will be a big benefit


Wolfgang 




AN Ashok N Syncfusion Team November 29, 2017 06:20 PM UTC

Hi Swo, 
 
Thanks for your update . You can write your custom style for GridCell in Application.Resources and bind that using GridTextColumn.CellStyle property, also you can change the GridTextColumn font size using CellTextSize property. Please refer the below code example: 
 
<Application.Resources> 
    <ResourceDictionary> 
        <Style x:Key="GridCellStyle" TargetType="sfgrid:GridCell"> 
            <Setter Property="BackgroundColor" Value="Yellow" /> 
            <Setter Property="Foreground" Value="Green" /> 
        </Style> 
    </ResourceDictionary> 
</Application.Resources> 
 
<sfgrid:GridTextColumn HeaderText="Order ID" MappingName="OrderID"  
       CellTextSize="20"  
       CellStyle="{StaticResource GridCellStyle}"> 
</sfgrid:GridTextColumn> 
 
 
Regards, 
Ashok 



AH Andrew Hoke September 7, 2021 10:51 PM UTC

I understand I'm reviving an old thread, but I figured it was better than posting the same question in a new thread.

We use SfDataGrid throughout our application on multiple pages where each data grid can have many columns. It's incredibly verbose to need to define the CellStyle explicitly when the CellStyle itself is a bindable property and could benefit from an implict style at the Application level rather than the page level.

Please reconsider requiring developers to explicitly set CellStyle and allow implicit styles to set the CellStyle property.



SV Suja Venkatesan Syncfusion Team September 8, 2021 01:26 PM UTC

Hi Andrew, 

Thank you for contacting Syncfusion support. 

We regret to let you know that DataGrid does not have support to apply the styles implicitly due to the current implementation architecture. So we request you to apply the cell styles explicitly as like in our previous update. 

Regards, 
Suja.  


Loader.
Up arrow icon