We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

MultiSelectComboBox filter with "select all except" button

Hi,
is it possible to extend MultiSelectComboBox filter and add "Select all except 1" option under "Select all" which will de/select all options in the list except options starting with "1"?

Thank you!

8 Replies

SS Susmitha Sundar Syncfusion Team February 4, 2020 01:39 PM UTC

Hi Ondrej Svoboda, 
 
Thank you for contacting Syncfusion support. 
 
We have understood your requirement, but we did not have MultiSelectComboBox control. Did you mean CheckboxFiltering or GridCheckBoxSelectorColumn? 
 
It will be helpful for us to check on it and provide you with the solution at the earliest.  
 
Regards, 
Susmitha S 



OS Ondrej Svoboda February 4, 2020 01:57 PM UTC

Hi,
I meant grid row filter editor control. FilterRowEditorType = "MultiSelectComboBox"


SS Susmitha Sundar Syncfusion Team February 5, 2020 06:55 PM UTC

Hi Ondrej Svoboda, 
 
 
Thank you for your update. 
 
You can achieve this by overriding the GridFilterRowMultiSelectRenderer class. Here we have added one of the ComboBoxItems as SelectAllExpect and Added filter predicates for this. 
C#: 
public void SetTextComboBoxItemsList() 
 { 
     textComboBoxItems = new List<string>(); 
     textComboBoxItems.Add("SelectAllExpect ALFKI"); 
     textComboBoxItems.Add("ALFKI"); 
     textComboBoxItems.Add("ANATR"); 
     textComboBoxItems.Add("AROUT"); 
     textComboBoxItems.Add("BLAUS"); 
     textComboBoxItems.Add("BOLID"); 
     textComboBoxItems.Add("BOTTM"); 
     textComboBoxItems.Add("BERGS"); 
     textComboBoxItems.Add("BLONP"); 
     textComboBoxItems.Add("BONAP"); 
     textComboBoxItems.Add("ANTON"); 
      
 } 
 
 
Screenshot: 
 
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Regards, 
Susmitha S 



OS Ondrej Svoboda February 6, 2020 02:17 PM UTC

Hi, thanks. Two more things:
  • you have static filter items - I need this to be dynamic - like in default renderer
  • when "SelectAllExpect ALFKI" is selected I would expect also all checkboxes in the filter except ALFKI are checked too - and when some of them is unchecked also "SelectAllExpect ALFKI" is unchecked (the same behavior as "Select all")
There could be also alternate solution for this - not having "SelectAllExpect ALFKI" as checkbox item but as a button somewhere which checks all except ALFKI checkboxes in the filter.

Sorry for making it more complicated :-)


SS Susmitha Sundar Syncfusion Team February 7, 2020 01:25 PM UTC

Hi Ondrej Svoboda, 
 
Thank you for your update. 
 
Please find the details for your update. 
 
Query 1: you have static filter items - I need this to be dynamic - like in default renderer 
 
We are not clear with your requirement. What did you mean by dynamic filter items? Do you want to add the select all expect 1, as dynamic item? Did you want to add that one item as dynamic?  
 
Query 2: when "SelectAllExpect ALFKI" is selected I would expect also all checkboxes in the filter except ALFKI are checked too - and when some of them is unchecked also "SelectAllExpect ALFKI" is unchecked (the same behavior as "Select all") 
 
We have modified the sample based on your requirement. We have added the conditions in OnComboBoxSelectionChanged() method. Please refer the below code, 
 
C#: 
  protected override void OnComboBoxSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) 
  { 
      ObservableCollection<string> ComboselectedItems = new ObservableCollection<string>(); 
      ObservableCollection<string> selectedItems = new ObservableCollection<string>(); 
      var comboBox = sender as ComboBoxAdv; 
      if ((e.AddedItems.Contains("SelectAllExpect ALFKI") && !comboBox.SelectedItems.Cast<string>().Contains("SelectAllExpect ALFKI")) || (e.AddedItems.Contains("SelectAllExpect ALFKI") && comboBox.SelectedItems.Cast<string>().Contains("SelectAllExpect ALFKI"))) 
      { 
          foreach (string item in comboBox.ItemsSource) 
          { 
              if (item != "ALFKI") 
                  selectedItems.Add(item); 
          } 
          comboBox.SelectedItems = selectedItems; 
      } 
      else if (!comboBox.SelectedItems.Cast<string>().Contains("ALFKI") && !comboBox.SelectedItems.Cast<string>().Contains("SelectAllExpect ALFKI") && comboBox.SelectedItems.Cast<string>().Count() == comboBox.Items.Count - 2) 
      { 
          foreach (string item in comboBox.ItemsSource) 
          { 
              if (item != "ALFKI") 
                  selectedItems.Add(item); 
          } 
          comboBox.SelectedItems = selectedItems; 
      } 
      else if(!comboBox.SelectedItems.Cast<string>().Contains("ALFKI") && comboBox.SelectedItems.Cast<string>().Contains("SelectAllExpect ALFKI") && comboBox.SelectedItems.Cast<string>().Count() >= 1) 
      { 
          foreach (string item in comboBox.SelectedItems) 
          { 
              if (item != "SelectAllExpect ALFKI") 
                  selectedItems.Add(item); 
          } 
          comboBox.SelectedItems = selectedItems; 
      } 
      else if(comboBox.SelectedItems.Cast<string>().Contains("ALFKI")) 
      { 
          foreach (string item in comboBox.SelectedItems) 
          { 
              if (item != "SelectAllExpect ALFKI") 
                  selectedItems.Add(item); 
          } 
          comboBox.SelectedItems = selectedItems; 
      } 
 
      base.OnComboBoxSelectionChanged(sender, e); 
  } 
   
 
 
Please check the sample and let us know if you need further assistance on this. 
 
Regards, 
Susmitha S 



OS Ondrej Svoboda February 7, 2020 01:54 PM UTC

By dynamic filter items I mean to fill filter item list from grid rows data (distinct data values in the column). Instead of having it hard-coded.


OS Ondrej Svoboda February 7, 2020 03:45 PM UTC

I figured this out by myself. Thanks for showing the direction anyway.


FP Farjana Parveen Ayubb Syncfusion Team February 10, 2020 09:10 AM UTC

Hi Ondrej, 
 
Thanks for the update. 
 
We are glad to know that the reported problem has been resolved at your end. Please let us know if you have any further queries on this. We are happy to help you. 
 
Regards, 
Farjana Parveen A 


Loader.
Up arrow icon