Current filter:
                                You should refresh the page.
                                  • Hi,
                                    I want to implement comma or space separated data row filter in dev express grid view, I want to the enter comma separated values for one column. can you help me with possible solution . either in data row filter or header filter for check box.

                                1 Solution

                                Creation Date Importance Sort by

                                Hello,
                                Please review the ASPxGridView - How to apply a custom filter by a comma separated string when using a filter row example where Lanette provided a solution on how to filter comma-separated strings via a filter row. This approach is implemented using the ProcessColumnAutoFilter event handler.

                                If you need to filter via a header filter, review the ASPxGridView - Header Filter - Filter data if a cell text is separated with a comma example, which uses the HeaderFilterFillItems event.

                                Let me know if you have any further questions.

                                • Customer99754 12.03.2019

                                  Hi Nataly,
                                  Thanks for the quick updated. The example two are not working form me.
                                  In data row  comma separated option , I can't use session variable, because I am writing the logic in .cs file. is there way we can write without session variable
                                  Hear is my code, The sample id is numeric number.
                                  settings.ProcessColumnAutoFilter = (sender, e) =>
                                              {

                                                  if (e.Column.FieldName == "SampleId")
                                                  {
                                                      if (e.Kind == GridViewAutoFilterEventKind.CreateCriteria)
                                                      {
                                                          string[] strContainerNumbers = e.Value.ToString().Split(',');
                                                          Session["filter"] = e.Value;
                                                          CriteriaOperator cop = new InOperator("SampleId", strContainerNumbers);
                                                          e.Criteria = cop;
                                                      }
                                                      else
                                                      {
                                                          if (Session["filter"] != null)
                                                              e.Value = Session["filter"].ToString();
                                                      }
                                                  }
                                              };
                                  2nd example with Header row filter
                                  when i try to enter comma separated in samplid, its not displaying any items to select.
                                  settings.HeaderFilterFillItems = (sender, e) => {
                                                   char separator = ',';
                                                  if (e.Column.FieldName != "SampleId")
                                                      return;
                                                  var result = e.Values
                                                                  .Select(q => q.Value.Split(separator))
                                                                  .SelectMany(q => q)
                                                                  .Distinct()
                                                                  .ToList();
                                                  e.Values.Clear();
                                                  foreach (var item in result)
                                                  {
                                                      CriteriaOperator cop = new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("SampleId"), item);
                                                      e.Values.Add(new FilterValue(item, item, cop.ToString()));
                                                  }

                                              };

                                  can you help me with the right example, where I can select filter with comma or space separated filer option for sampleID(numeric value)

                                • Customer99754 12.03.2019

                                  Hi Nataly,
                                  Thanks for the quick updated. The example two are not working form me.
                                  In data row  comma separated option , I can't use session variable, because I am writing the logic in .cs file. is there way we can write without session variable
                                  Hear is my code, The sample id is numeric number.
                                  settings.ProcessColumnAutoFilter = (sender, e) =>
                                              {
                                                  if (e.Column.FieldName == "SampleId")
                                                  {
                                                      if (e.Kind == GridViewAutoFilterEventKind.CreateCriteria)
                                                      {
                                                          string[] strContainerNumbers = e.Value.ToString().Split(',');
                                                          Session["filter"] = e.Value;
                                                          CriteriaOperator cop = new InOperator("SampleId", strContainerNumbers);
                                                          e.Criteria = cop;
                                                      }
                                                      else
                                                      {
                                                          if (Session["filter"] != null)
                                                              e.Value = Session["filter"].ToString();
                                                      }
                                                  }
                                              };
                                  2nd example with Header row filter
                                  when i try to enter comma separated in samplid, its not displaying any items to select.
                                  settings.HeaderFilterFillItems = (sender, e) => {
                                                   char separator = ',';
                                                  if (e.Column.FieldName != "SampleId")
                                                      return;
                                                  var result = e.Values
                                                                  .Select(q => q.Value.Split(separator))
                                                                  .SelectMany(q => q)
                                                                  .Distinct()
                                                                  .ToList();
                                                  e.Values.Clear();
                                                  foreach (var item in result)
                                                  {
                                                      CriteriaOperator cop = new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty("SampleId"), item);
                                                      e.Values.Add(new FilterValue(item, item, cop.ToString()));
                                                  }
                                              };
                                  can you help me with the right example, where I can select filter with comma or space separated filer option for sampleID(numeric value)

                                • Vova (DevExpress Support) 12.04.2019

                                  Hello,

                                  In data row  comma separated option , I can't use session variable, because I am writing the logic in .cs file. is there way we can write without session variable

                                  As I see, we answered this question in the How to access the Session object in a separate class ticket. Please check it and don't hesitate to reactivate it if you have any further questions.

                                  2nd example with Header row filter

                                  I'm not sure that it's necessary to implement your own filter with several separate values. Please refer to the Header Filter demo and see the "Enable CheckedList mode" check box. In this mode, you can place several items in a header filter:

                                  In this case ASPxGridView will show only records with "Argentina" or "Belgium" country. I believe this will meet your requirements. Let me know your results.

                                  Regards,
                                  Vova