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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MultiSelectComboBox filter with "select all except" button

Thread ID:

Created:

Updated:

Platform:

Replies:

151199 Feb 3,2020 02:28 PM UTC Feb 10,2020 09:10 AM UTC WPF 8
loading
Tags: SfDataGrid
Ondrej Svoboda
Asked On February 3, 2020 02:28 PM UTC

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!

Susmitha Sundar [Syncfusion]
Replied On 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 


Ondrej Svoboda
Replied On February 4, 2020 01:57 PM UTC

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

Susmitha Sundar [Syncfusion]
Replied On 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 


Ondrej Svoboda
Replied On 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 :-)

Susmitha Sundar [Syncfusion]
Replied On 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 


Ondrej Svoboda
Replied On 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.

Ondrej Svoboda
Replied On February 7, 2020 03:45 PM UTC

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

Farjana Parveen Ayubb [Syncfusion]
Replied On 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 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon