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: String representation of enums in FilterRow

Thread ID:

Created:

Updated:

Platform:

Replies:

55375 Jan 29,2007 03:53 PM UTC Feb 1,2007 12:07 AM UTC WinForms 3
loading
Tags: GridControl
Henning Möller
Asked On January 29, 2007 03:53 PM UTC

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

Administrator [Syncfusion]
Replied On 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

Administrator [Syncfusion]
Replied On 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?

Administrator [Syncfusion]
Replied On 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

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.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

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

;