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
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set the color based on field data

Thread ID:





143103 Mar 5,2019 08:40 AM UTC Mar 7,2019 05:08 AM UTC ASP.NET Core - EJ 2 3
Tags: DataGrid
Mohd Mohaimin Zakaria
Asked On March 5, 2019 08:40 AM UTC


I have a grid as shown example below, how can i set the color for the text field data in a column based on difference between 2 columns.

            <e-grid-column field="OldValue" headerText="OldValue"></e-grid-column>
            <e-grid-column field="NewValue" headerText="NewValue"></e-grid-column>

Example :

Old ValueNew Value

As per example, I want the text in New Value column which are Different than Old Value column.
In this case I want 200g, Brown & $2 to be in red color. Other than that is default black color.

Thank you.

Thavasianand Sankaranarayanan [Syncfusion]
Replied On March 6, 2019 05:20 AM UTC

Hi Mohd, 

Greetings from Syncfusion. 

We can achieve your requirement using the rowDataBound event of Grid. 

Refer the below code example. 

<ejs-grid id="Grid" dataSource="ViewBag.dataSource" allowPaging="true" rowDataBound="rowDataBound"> 
        <e-grid-column field="OldValue" headerText="OldValue" width="90"></e-grid-column> 
        <e-grid-column field="NewValue" headerText="NewValue" width="90"></e-grid-column> 
    .e-grid td.e-rowcell.differentValue { 
        color: red; 
    function rowDataBound(args){ 
        if (args.data.OldValue != args.data.NewValue) 

Refer the below screen shot. 


Refer the help documentation. 

Please let us know if you need further assistance on this.  

Thavasianand S. 

Mohd Mohaimin Zakaria
Replied On March 6, 2019 06:49 AM UTC

Got it. Thanks!

Thavasianand Sankaranarayanan [Syncfusion]
Replied On March 7, 2019 05:08 AM UTC

Hi Mohd, 
We are happy that the problem has been solved. 
Please get back to us if you need any further assistance.  
Thavasianand S.                         


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon