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

Change Column Cells background based on value

Dear admin,

im trying a lot with your datagrid but dont find a solution for changing the backgroundcolor of cells, which are part of one specific column. F.e. they should change to green if process is completed else they should be red. The values of the columns get loaded by database. Datagrid already takes cellstyle and the cellstyle should only affect background property to the cells in the specific column. Hope you can help me further and my project is in MVVM style.

Regards.

1 Reply

JN Jayaleshwari N Syncfusion Team December 14, 2018 10:16 AM UTC

Hi Sascha, 
 
Thanks for contacting Syncfusion Support. 

We have checked the reported query “Change Column Cells background based on value” from our side. You can achieve your requirement by using CellStyle property GridColumn and using converter in style.
 
 
Code snippet XAML: CellStyle applied to specific column. 
 
<Window.Resources> 
    <local:ColorConverter x:Key="converter"/> 
</Window.Resources> 
 
<syncfusion:GridTextColumn HeaderText="Order  id" MappingName="OrderID"> 
    <syncfusion:GridTextColumn.CellStyle> 
        <Style TargetType="syncfusion:GridCell"> 
            <Setter Property="Background" Value="{Binding Path=OrderID,Converter={StaticResource converter}}"/> 
        </Style> 
    </syncfusion:GridTextColumn.CellStyle> 
</syncfusion:GridTextColumn> 
 
We have attached the sample for your reference and you can download the sample from the following location. 
 
We have already published UG and KB for this use case and you can refer from the following locations. 
 
Please let us know if you would require further assistance. 
 
Regards, 
Jayaleshwari N. 


Loader.
Live Chat Icon For mobile
Up arrow icon