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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

GridGroupingControl: How to Change Cell Color on Property value?

Thread ID:

Created:

Updated:

Platform:

Replies:

112516 Sep 26,2013 07:51 AM UTC Oct 4,2013 04:34 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Suhas Dhongade
Asked On September 26, 2013 07:51 AM UTC

I want to change cell color depending on property value.  this property is not a visible/hided coulmn.

its a asp.net web application.

suppose.. I have bound  List<Emp> and

EMP - name , salary , department, gender

Gender is not any column on the GridGroupingControl. It just a property of EMP(either Male/Female).

Now I want change color of "Name" cell who is belongs to Male value

 

    


Shanmugaraja K [Syncfusion]
Replied On October 4, 2013 04:34 AM UTC

Hi Suhas,

 

Thanks for using Syncfusion products.

 

Your requirement of changing the cell color depending on  the property value which did not included in hidden/visible columns in Grid  can be achieved by using RowDataBound Event. Please refer to the below code snippet to achieve this.

 

[CS]

void GridGroupingControl1_RowDataBound(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.RowDataBoundEventArgs e)

 {

 for (int i = 0; i < e.Row.Cells.Count; i++)

            {

            if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor != null)

                {

                   if (((Syncfusion.Web.UI.WebControls.Grid.Grouping.GridCell)(e.Row.Cells[i])).ColumnDescriptor.Name == "Name")

                    {

                      if ((e.Row.Record!=null) && (e.Row.Record.GetValue("Gender") == "Male"))

                        {

                          e.Row.Cells[0].BackColor = Color.Green;

                        }

}}}}

 

Please refer to the attached sample application for further reference.

 

Please get back to us if you need further assistance.

 

Regards,

Shanmugaraja



WebformSample_98767d5e.zip

CONFIRMATION

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.

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

;