Markus Hastreiter
10.24.2008
I've created and attached a small sample project to illustrate the issue.
Hello Markus,
You are right. A solution is to make the grid use the Contains filter instead of the default filter for your "Category" column. The grid column's FilterMode should be set to DisplayText. To accomplish this task, you should create a grid's descendant as shown in the How to create a GridView descendant class and register it for design-time use article and override the ApplyColumnFilter method for the GridView descendant.
If you run into any further difficulty, please don't hesitate to ask.
Thank you,
Paul
Sorry, looking at your code I just realized that maybe I didn't describe my intentions well enough or we have different interpretations of a "Contains" filter.
For clearification: I have a property string[] Categories and I use a formatter to show these categories comma separated in one cell. But I don't want the filter criteria to parse the display text (which would be the result of the formatter, e.g. "Holiday, International").
I would like to be able to filter by the original string[]. So in my understanding I need to write a new filter criteria which gets the original property value as type string[] and can inspect whether any of the items within this array matches the category which was selected as filter criteria.
So I don't want a "Contains" operation on the display text but instead a "Contains" operation on the original string array. Parsing the string would be error prone because I can't guarantee that a category name doesn't contain another category name by accident (e.g. "Holiday" and "International Holiday")
Is this possible and if so, how?
Thanks,
Markus
Ok, thanks for the answer.
I've decided to use the like-filter for now (instead of a contains operation on the string[]).
Just wanted to let you know: I was able to accomplish the like-filtering without the need of a GridControl descendant.
Instead (after looking at your code using reflector) when populating the autofilter popup, I create FilterItems which already know "their" ColumnFilterInfo (which contains the filter criteria as string).
Example:
void uxGridView_ShowFilterPopupListBox(object sender, DevExpress.XtraGrid.Views.Grid.FilterPopupListBoxEventArgs e)
[...]
ColumnFilterInfo columnFilterInfo = new ColumnFilterInfo(String.Format("[{0}] like '%{1}%'", e.Column.FieldName, item.ToString()));
e.ComboBox.Items.Add(new DevExpress.XtraGrid.Views.Grid.FilterItem(item.ToString(), columnFilterInfo));
with item being for example "Holiday".
Best regards,
Markus
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+