Current filter:
                                You should refresh the page.
                                0
                                  • Hi,

                                    I have a requirement similar to the "Multiple Values Grouping" example in your Demo Center. But my focus right now is not the "grouping" feature but instead to support easy filtering of the categories.
                                    Each row represents one object and each object has a property "Category" of type string[]. So if an object has assigned two categories this value is for example { "Goals", "Holiday" }.
                                    I've already written a formatter to display the content of this string array in one cell.

                                    Now I would like to support easy filtering using the column popup filter. Right now this filter shows either nothing (when set to ColumnFilterMode.Value) or the content of the cells (when set to ColumnFilterMode.DisplayText). But this means the popup filter shows values like "Goals, Holiday" (as in your example) but I would like the user to be able to select each possible category separately so that only items are shown that have the selected categories assigned. Using the ShowFilterPopupListBox event I already managed to show each available category separately but when selecting a filter item the result is not as expected (no rows are displayed any more and the applied filter shown in the filter panel looks something like [Categories] = 'G', 'o', 'a', 'l', 's'.

                                    I think I have to implement my own FilterCriteria or my own ColumnFilterInfo or something like that. But I can't figure out how to implement this feature. I think I need a FilterCriteria that is able to execute a "containts" operation on the string[] property.
                                    Could you please advice me on how to proceed or give me some code example?
                                    (right now we're still using 7.3.7 but we will migrate to 8.2 the next few weeks so if it will only work with your newest release thats ok)

                                    Thanks in advance,
                                    Markus

                                0

                                I've created and attached a small sample project to illustrate the issue.

                                SingleCategoryFiltering.zip
                                0

                                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

                                0

                                The method ColumnView.ApplyColumnFilter is marked internal protected, so it's not possible to override it.
                                Is there another way?

                                Thanks,
                                Markus

                                0

                                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

                                0

                                Hello Markus,

                                Unfortunately, the grid doesn't support this ability. I recommend that you provide custom filtering using the GridView.CustomRowFilter event instead of filtering via a column's filter.

                                Thank you,
                                Paul

                                0

                                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

                                0

                                Found an alternative solution

                                You must  log in  or  register  to leave an answer

                                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.