GridGroupingControl Conditional Formatting

I cannot figure out how to format text color in one cell based on a value in a different cell in the same row.



3 Replies

AD Administrator Syncfusion Team March 3, 2008 05:43 AM UTC

Hi Richard,

Thank you for your patience.

Issue 1: how to format text color in one cell based on a value in a different cell in the same row.

You can able to set the text color in one cell based on a value in another cell in the same row when clicking the Apply Conditions button by using GridGroupingControl1 QueryCellStyleInfo event. The following code snippet is used to achieve this behavior:


protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (Buttonclick == 1)
{
if (e.TableCellIdentity.RowIndex > 3)
{
if (e.TableCellIdentity.ColIndex == 6)
{
FirstCellValue = e.Style.CellValue.ToString();
}

if (e.TableCellIdentity.ColIndex == 7)
{
SecondCellValue = e.Style.CellValue.ToString();
}

if (FirstCellValue.ToString().Length > 0 && SecondCellValue.ToString().Length > 0)
{
if (Convert.ToDouble(FirstCellValue) > Convert.ToDouble(SecondCellValue))
{
if (e.TableCellIdentity.ColIndex == 7)
{
e.Style.TextColor = Color.Red;
}

}
}
}

}

}


Please refer the sample in the below link which illustrates the above:

http://websamples.syncfusion.com/samples/Grid.Web/6.1.0.34/72077/main.htm

Please try running the above sample and let me know if this helps.

Regards,
Vishnu.






DA Dave March 12, 2008 07:55 PM UTC

I have only been able to get this to work when I turn "Auto Format" off. I would prefer to leave "Auto Format" on and then override the targeted cells. Can you please tell me how to do this?





DA Dave March 13, 2008 12:02 AM UTC

Please disregard this. I have asked the question under a new thread.

http://www.syncfusion.com/support/forums/message.aspx?&MessageID=72305



>I have only been able to get this to work when I turn "Auto Format" off. I would prefer to leave "Auto Format" on and then override the targeted cells. Can you please tell me how to do this?






Loader.
Up arrow icon