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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
September 5, 2006 11:06 AM UTC
@Haneef, any suggestion how to solve this issue?
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
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
AD
Administrator
Syncfusion Team
September 6, 2006 11:27 AM UTC
Hi,
thank your for your clarification - I will take a closer look at this help item.