GGC: String representation of enums in FilterRow
I wonder if there is a way to have the filter row list the available coices of an enum typed field as strings instead of index values.
The record grid rows perfectly convert the index into the string representation of the enum without a problem. Unfortunately, the filter row doesn't.
I've already created a GridTableFilterBarCellModel for the filter bar according to this KB article:
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=323
I expected it to be pretty straight forwared to convert the added items to their appropriate string representation in FillWithChoices, but I don't really get how to convert the type because I get boxed integers instead of enum objects as a result of the call to GetFilterBarChoices.
Any hints?
TIA
Henning
The record grid rows perfectly convert the index into the string representation of the enum without a problem. Unfortunately, the filter row doesn't.
I've already created a GridTableFilterBarCellModel for the filter bar according to this KB article:
http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=323
I expected it to be pretty straight forwared to convert the added items to their appropriate string representation in FillWithChoices, but I don't really get how to convert the type because I get boxed integers instead of enum objects as a result of the call to GetFilterBarChoices.
Any hints?
TIA
Henning
SIGN IN To post a reply.
3 Replies
AD
Administrator
Syncfusion Team
January 29, 2007 06:36 PM UTC
Hi HMoeller,
Here is a minimal sample that implements the enum filters in a grid. Please try the attached sample and let me know if you are trying something different.
Customize Dropdownlist.zip
Best Regards,
Haneef
Here is a minimal sample that implements the enum filters in a grid. Please try the attached sample and let me know if you are trying something different.
Customize Dropdownlist.zip
Best Regards,
Haneef
AD
Administrator
Syncfusion Team
January 30, 2007 12:25 PM UTC
Hi Haneef,
thanks for the quick reply. It helped a lot.
But there's still one problem: If I group by some of my enum fields, the grid displays group header rows. The caption can be defined using those "macros" like {Category}. Unfortunately, {Category} still returns the index of the enum instead of the string.
Some hook to fix this?
thanks for the quick reply. It helped a lot.
But there's still one problem: If I group by some of my enum fields, the grid displays group header rows. The caption can be defined using those "macros" like {Category}. Unfortunately, {Category} still returns the index of the enum instead of the string.
Some hook to fix this?
AD
Administrator
Syncfusion Team
February 1, 2007 12:07 AM UTC
Hi HMoeller,
You can handle the QueryCellStyleInfo event of the grid and set the e.Style.Text property for GroupCaptioncell in Enumeration grouped column. Here is a code snippet.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
Element el = e.TableCellIdentity.DisplayElement;
if( el.ParentGroup != null && el.ParentGroup.Name == "Col3") //Enumeration Column.
{
if( el.ParentGroup.Category.ToString() != null)
{
string Category = Enum.GetName(typeof(Days),el.ParentGroup.Category);
string GroupName = el.ParentGroup.Name;
int Count= el.ParentGroup.Records.Count;
e.Style.Text = string.Format("{0}-{1}-{2} Items",GroupName,Category,Count);
}
}
}
}
Please refer to the attached sample for implementation.
Customize Dropdownlist.zip
Best Regards,
Haneef
You can handle the QueryCellStyleInfo event of the grid and set the e.Style.Text property for GroupCaptioncell in Enumeration grouped column. Here is a code snippet.
private void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if( e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
Element el = e.TableCellIdentity.DisplayElement;
if( el.ParentGroup != null && el.ParentGroup.Name == "Col3") //Enumeration Column.
{
if( el.ParentGroup.Category.ToString() != null)
{
string Category = Enum.GetName(typeof(Days),el.ParentGroup.Category);
string GroupName = el.ParentGroup.Name;
int Count= el.ParentGroup.Records.Count;
e.Style.Text = string.Format("{0}-{1}-{2} Items",GroupName,Category,Count);
}
}
}
}
Please refer to the attached sample for implementation.
Customize Dropdownlist.zip
Best Regards,
Haneef
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
HM Henning Möller
- Jan 29, 2007 03:53 PM UTC
- Feb 1, 2007 12:07 AM UTC