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

GGC GridConditionalFormat

Thread ID:

Created:

Updated:

Platform:

Replies:

48766 Sep 4,2006 02:23 PM UTC Sep 6,2006 11:27 AM UTC WinForms 7
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On September 4, 2006 02:23 PM UTC

Hi,

we are using a GGC in our application. The gui which contains the grid component offers the user to change the column format (style) via the GridTableCellStyleInfo object. Furthermore the user can define some conditional format for the grid via the ConditionalFormats property. Now there is an interference between the two format settings. As an example.

The user defines for a column "A" that the cell background should be blue. Furthermore he defines a conditional format that for all cells which match the conditional rule - the cell background should be red.

Now for the cells who match both style settings, the conditional rule will be ignored. How can I give the conditional rule the "highest priority".

Hope you understand my question

Cheers,
Tim

Administrator [Syncfusion]
Replied On September 5, 2006 04:55 AM UTC

Hi Tim,

The first added GridConditionalFormat has a higher priority than the second one. I have created the sample as per your requirement. The Attached works fine with the GridConditionalFormat and let me know if you are looking something different.

GridConditionalFormatDescriptor Format3 = new GridConditionalFormatDescriptor("Row3");
Format3.Expression = Format1.Expression + " AND " + Format2.Expression;

//You need to set the default grid setting to cell.(ie Default backcolor of the cell is SystemColors.Window)
Format3.Appearance.AnyRecordFieldCell.BackColor = SystemColors.Window;

this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(Format3);

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_Foramt_ae5f1460.zip

Thanks
Haneef

Administrator [Syncfusion]
Replied On September 5, 2006 06:06 AM UTC

Hi Haneef,

thanks for your sample - I understand that the first added GridConditionalFormat has a higher priority as the second and so on.. The problem is that if I set a format for a column via the GridTableCellStyleInfo object of the column than this setting overrides the GridConditionalFormat setting. How can I avoid this?

Cheers,
Tim

>Hi Tim,

The first added GridConditionalFormat has a higher priority than the second one. I have created the sample as per your requirement. The Attached works fine with the GridConditionalFormat and let me know if you are looking something different.

GridConditionalFormatDescriptor Format3 = new GridConditionalFormatDescriptor("Row3");
Format3.Expression = Format1.Expression + " AND " + Format2.Expression;

//You need to set the default grid setting to cell.(ie Default backcolor of the cell is SystemColors.Window)
Format3.Appearance.AnyRecordFieldCell.BackColor = SystemColors.Window;

this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(Format3);

Here is a sample.
http://www.syncfusion.com/Support/user/uploads/GGC_Foramt_ae5f1460.zip

Thanks
Haneef

Administrator [Syncfusion]
Replied On September 5, 2006 11:06 AM UTC

@Haneef, any suggestion how to solve this issue?

Administrator [Syncfusion]
Replied On September 5, 2006 12:45 PM UTC

Hi Tim,

Before setting the GridTableCellStyleInfo properties, you need to evaluate the condition for the given record using CompareRecord method. Here is a code snippet.

GridTableCellStyleInfo style = e.Inner.Style as GridTableCellStyleInfo;
Element el = style.TableCellIdentity.DisplayElement;
if( el.Kind == DisplayElementKind.Record)
{
flag =false;
IsprepareViewStyleInfo = true;

foreach(GridConditionalFormatDescriptor gd in e.TableControl.TableDescriptor.ConditionalFormats)
{
//Evaluates this condition for the given record and returns True if the record meets the condition.
if( ! gd.CompareRecord( el.ParentRecord) )
{
flag = true;
break;
}
}
IsprepareViewStyleInfo = false;
if( flag)
{
e.Inner.Style.BackColor = Color.Gold;
}
}

Here is a modified sample.
http://www.syncfusion.com/Support/user/uploads/GGC_modifiedForamt_c5e19c3e.zip

Let me know if this helps.
Best Regards,
Haneef

Administrator [Syncfusion]
Replied On September 5, 2006 01:45 PM UTC

Hi Haneef,

thanks for your further sample. I am not really sure if I understand your sample completely. But I think after I have set the style for a column via:

TableDescriptor.Columns["Name"].Appearance.AnyRecordFieldCell

I have to check in the TableControlPrepareViewStyleInfo event if a record is also affected by a conditional format. If this is the case I have to set the style of the affected record manually? Or should I apply the conditional format explicitly for this record?

Cheers,
Tim

Administrator [Syncfusion]
Replied On September 6, 2006 11:13 AM UTC

Hi Tim ,

Sorry for the inconvenence caused.

The reason is that the Columns[ index]''s GridTableCellStyleInfo is higher priority than GridFormatDescriptor''s GridTableCellStyleInfo.( Columns[ index]''s GridTableCellStyleInfo like ColStyle in a GridControl and GridFormatDescriptor''s GridTableCellStyleInfo like a RowStyle ). You have to set the style of the affected record manually in PrepareViewStyleInfo / QueryCellStyleInfo event.

For more information, See the StyleInfo Priority:

The GridStyleInfoAtWork sample shows you the relationship between a standard style, the table style, a basestyle, a row style, a column style and a cell style. It lets you set a color for each one of these, and lets you choose whether or not you want the style included. While working with these options, you will be able to see the precedence relationship among the styles.

Here is a path.
[InstalDrive]\Syncfusion\Essential Studio\4.3.0.0\windows\Grid.Windows\Samples\Quick Start\GridStyleInfoAtWork

Let me know if this helps.
Regards,
Haneef

Administrator [Syncfusion]
Replied On September 6, 2006 11:27 AM UTC

Hi,

thank your for your clarification - I will take a closer look at this help item.

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

;