This is a migrated thread and some comments may be shown as answers.

[Solved] How to set FilterExpression for GridBoundColumn that is an Enum in Codebehind?

5 Answers 184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chris Marisic
Top achievements
Rank 1
Chris Marisic asked on 04 Feb 2010, 03:36 PM
If I have a column named Source which corresponds to a property of MySourceEnum Source how do I write a filter expression for this?

So far everything I've tried along the lines of

RadGrid1.MasterTableView.FilterExpression = "[Source] = 'SourceEnumValue'" 

Keeps resulting in a server exception.

Should I be using something like MySourceEnum.SourceEnumValue or perhaps the concrete name Some.Name.Space.MySourceEnum.SourceEnumValue isntead?

Also I should point out I use Nullable enums on my object incase it could be an issue with the grid not handling nullable enums correctly.

5 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 09 Feb 2010, 02:35 PM
Hi Chris,

Could you please send us a sample code illustrating your scenario and the faced problems? We will try debugging it and turn back to you with our findings.

Looking forward your reply,
Iana
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Andy F.
Top achievements
Rank 1
Iron
answered on 11 Feb 2010, 04:41 PM
Having similar issue, except I'm doing it server-side using FilterExpression against a dataset that is a List<> of custom objects.  Can't figure out what to specify that will make it properly filter on an Enum property.  Tried the integer, tried the string, tried the string without quotes.  Answer is non-obvious.  Let me know what you figure out.
0
Chris Marisic
Top achievements
Rank 1
answered on 11 Feb 2010, 05:28 PM
I got it working with this syntax (which I believe is the LINQ filter syntax as opposed to SQL-like)

 
RadGrid1.MasterTableView.FilterExpression = "Source = \"EnumName\"" 

0
Andy F.
Top achievements
Rank 1
Iron
answered on 11 Feb 2010, 05:57 PM
Thanks, Chris, but I'm working in 2.0, so Linq expressions are supported.  Still stuck.... :(
0
Iana Tsolova
Telerik team
answered on 16 Feb 2010, 12:26 PM
Hi,

I tried following your scenario in the attached sample. Please check it out and let me know if it works as desired or if I missed something there out.
 
Regards,
Iana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Grid
Asked by
Chris Marisic
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Andy F.
Top achievements
Rank 1
Iron
Chris Marisic
Top achievements
Rank 1
Share this question
or