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

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

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


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?


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

Loader.
Live Chat Icon For mobile
Up arrow icon