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

Expressions of conditional formatting

Hi guys,

I want to use conditional formatting using GridConditionalFormatDescriptor class, however I could not find any documentation about its Expression property.
I tried to assign a condition where values of two columns are equal but it didn't work:

GridConditionalFormatDescriptor formatDesc = new GridConditionalFormatDescriptor();
formatDesc.Name = "xy";
formatDesc.Expression = "[Col1]=[Col2]";

How can I make this work?

Also, how can I use one of the members of column's ExtendedProperties collection in this expression?

Thanks,
Peter


2 Replies

RP Rekha P Syncfusion Team April 2, 2009 12:08 PM UTC

Hi Peter,

Thank you for your interest in Syncfusion Products.

If your intension is to check for a condition between two columns, you can use RowDataBound event which iterates through each row with the grid cells. Please refer the code
snippet below to achieve this.


void GridGroupingControl1_RowDataBound(object sender, RowDataBoundEventArgs e)
{
//Check if the current element is a Record row.
if (e.Element.Kind.ToString() == "Record")
{
for (int i = 0; i < e.Row.Cells.Count; i++)
{
if (((GridCell)(e.Row.Cells[i])).ColumnDescriptor.MappingName == "Check")
{
GridRow gridrow1 = e.Row;
int a = Convert.ToInt32(gridrow1.Record.GetValue("Value1")); //Col1
int b = Convert.ToInt32(gridrow1.Record.GetValue("Value2")); //Col2
if (a == b)
{
e.Row.Cells[i].Text = "Equal";
}
else
{
e.Row.Cells[i].Text = "Not Equal";
}
}
}
}
}


Please refer the sample below which illustrates the above.
http://files.syncfusion.com/support/GGC.Web/7.1.0.30/F80386/main.htm

The Equal(==) defined in Expression returns true if both arguments have same value, for instance "[Salary]=20000".

We request you to create a DirectTrac Incident using your DT account for further support and please let me know if you have any concerns.

Thanks,
Rekha




PK Peter Kovacs April 2, 2009 03:40 PM UTC

Hi,

thanks for the response, this solution seems to solve my problem. I'll get back to you when I try it.

thanks,
Peter


Loader.
Live Chat Icon For mobile
Up arrow icon