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

Auto format and grid customization

I would like to use one of the themes provided through Auto Format and then I would like to change properties of cells at runtime. (I.e. change cell background color based on value in another cell). Unfortunately, I have only been able to get this to work when I turn "Auto Format" off. I am new to this and would appreciate your help. I imagine the Auto Format is getting applied after the execution of the following:

protected void GridGroupingControl1_QueryCellStyleInfo(object sender, Syncfusion.Web.UI.WebControls.Grid.Grouping.GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AnyRecordFieldCell)
{
if ((e.TableCellIdentity.Column.Name == "division") && (e.Style.CellValue.ToString() == "MTD"))
{
e.Style.BackColor = System.Drawing.Color.Red;
}
}
}






4 Replies

AD Administrator Syncfusion Team March 14, 2008 06:38 AM UTC

Hi Dave,

Thank you for your interest in Syncfusion Products.

You have to override the autoformat in order to change properties of cells at runtime. Please use below code snippet to achieve this:



[C#]

protected void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if (e.TableCellIdentity.TableCellType == GridTableCellType.AlternateRecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.RecordFieldCell || e.TableCellIdentity.TableCellType == GridTableCellType.AnyRecordFieldCell)
{
if ((e.TableCellIdentity.Column.Name == "Header0") && (e.Style.CellValue.ToString() == "2,0"))
{
//Override autoformat
e.Style.CssClass = "MyGreenTextStyle";
}
}

}

[CSS]

.MyGreenTextStyle
{
background-color:Lime;
}




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

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

Please try this and let me know if this helps.

Thanks,
Melba






RI Ricardo Ismael Sanchez Condori March 3, 2010 08:34 PM UTC


Hi,

the link is broken, the correct link please.

Greetings and thnks


RI Ricardo Ismael Sanchez Condori March 3, 2010 10:39 PM UTC



JB Jaffersathick B Syncfusion Team March 4, 2010 06:19 AM UTC

Hi Ricardo,

Thank you for your interest in Syncfusion products.

We glad to know that you found the correct link. Please let us know if you have any other concerns. We will be happy to help you out.

Regards,
Jaffer.B

Loader.
Live Chat Icon For mobile
Up arrow icon