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

                                    I have implemented a customRowFilter (code provided below) in order to ignore accent and case while user is searching the grid.

                                    My problem is if a user applies a filter to the list using the filter editor and then use a search box which is bind to the TableView.SearchString.

                                    Instead of having an AND between FilterString and SearchString, it seems to be an OR.

                                    How can I achieve to have an AND instead of an OR between those two criteria?



                                    private List<GridColumn> _searchableColumns; private void OnCustomRowFilter(object sender, RowFilterEventArgs e) { if (string.IsNullOrEmpty(View.SearchString) || e.Handled) return; if (_searchableColumns == null) { _searchableColumns = new List<GridColumn>(); foreach (var c in Columns) { if (c.FieldType == typeof(bool) || !c.AllowAutoFilter) continue; _searchableColumns.Add(c); } } var filter = RemoveDiacriticsCustom(View.SearchString).ToLower(); e.Visible = false; for (var i = 0; i < _searchableColumns.Count; i++) { var processedString = RemoveDiacriticsCustom(GetCellDisplayTextByListIndex(e.ListSourceRowIndex, _searchableColumns[i])).ToLower(); if (processedString.Contains(filter)) { e.Visible = true; break; } } e.Handled = true; } private static string RemoveDiacriticsCustom(string text) { return string.Concat(text.Normalize(NormalizationForm.FormD).Where(ch => CharUnicodeInfo.GetUnicodeCategory(ch) != UnicodeCategory.NonSpacingMark)).Normalize(NormalizationForm.FormC); }

                                1 Solution

                                Creation Date Importance Sort by

                                Hi Gaetan,

                                The CustomRowFilter is intended to override the result of the default filtering. So, you will need to either take the FilterString property value into account, or use a different event.

                                I suggest you consider using the SearchStringToFilterCriteria event instead, where you can specify how to convert the search string to a filter criteria. For example, create a custom function criteria operator that will remove diacritics and use it in the SearchStringToFilterCriteria event handler. I have attached a sample with your RemoveDiacriticsCustom method where you can see this approach.


                                • Customer66162 10.11.2019

                                  Hi Ivan,

                                  I like your suggestion since it seems to be more integrated in the DevExpress pipeline.

                                  While waiting for your help, I continued to analyze DevExpress Searching/Filtering pipeline and I found that I could modify the method below in order to achieve searching and ignoring accent.

                                  Without modifying DevExpress code, is there a way to implement a SearchStringToFilterCriteria custom function that uses the modified code below.



                                  static bool? FnContainsCaseInsensitive(string str1, string str2) { if(str1 == null || str2 == null) return null; //return // str1.IndexOf(str2, StringComparison.InvariantCultureIgnoreCase) >= 0 || // str1.IndexOfInvariantCultureIgnoreCase(str2) >= 0; var compareInfo = CultureInfo.InvariantCulture.CompareInfo; return compareInfo.IndexOf(str1, str2, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) > -1; }
                                • André (DevExpress Support) 10.11.2019


                                  As far as I understand, you want to create a custom Contains function operator. If so, would you please clarify if you tried Ivan's approach? If you encountered some issues, please modify his project to demonstrate your implementation.