multiselect column in datagrid

Dear,

Is it possible to have a multiselect dropdown column in a SfDataGrid? 
I have a class MyClass that I would like to show in a datagrid with columns "Name" and "Types", where the "Types" column is a multiselect listbox/dropdown...

class MyClass {
public int Id { get; set; } public string name {get; set;} public virtual ICollection(MyClassType) Types {get; set;}
}
class MyClassType {
public int Id { get; set; } public string name {get; set;}
public virtual ICollection(MyClass) Classes {get; set;}
}

How can I do this in WPF?
Thanks,
Koen

6 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team February 18, 2021 03:38 PM UTC

Hi Koen,

Thank you for contacting Syncfusion support.

Your requirement can be achieved by using GridMultiColumnDropDownList in SfDataGrid.

For more information, please refer the below UG link,

UG Link:
https://help.syncfusion.com/wpf/datagrid/column-types#gridmulticolumndropdownlist 
We hope this helps. Please let us know, if you require further assistance on this.

Regards,
Vijayarasan S
 



KO Koen replied to Vijayarasan Sivanandham February 18, 2021 03:43 PM UTC

Hi Koen,

Thank you for contacting Syncfusion support.

Your requirement can be achieved by using GridMultiColumnDropDownList in SfDataGrid.

For more information, please refer the below UG link,

UG Link:
https://help.syncfusion.com/wpf/datagrid/column-types#gridmulticolumndropdownlist 
We hope this helps. Please let us know, if you require further assistance on this.

Regards,
Vijayarasan S
 


Dear,
I don't see how a multicolumn dropdown would help to allow multiselect?
Thanks,
Koen


MA Mohanram Anbukkarasu Syncfusion Team February 19, 2021 11:27 AM UTC

Hi Koen, 

We regret for the inconvenience.  

You can achieve your requirement to select multi values from the dropdown for the collection in the underlying  data object by using GridTemplateColumn with ComboBoxAdv as CellTemplate as shown in the following code example.  

Code example :  

<syncfusion:GridTemplateColumn MappingName="ShipCities"> 
     <syncfusion:GridTemplateColumn.CellTemplate> 
         <DataTemplate> 
             <syncfusion:ComboBoxAdv ItemsSource="{Binding Cities, Source={StaticResource viewModel},UpdateSourceTrigger=PropertyChanged}"  
                                     DisplayMemberPath="ShipCityName"  
                                     SelectedValuePath="ShipCityName" 
                                     AllowMultiSelect="True"  
                                     SelectedItems="{Binding ShipCities, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> 
         </DataTemplate> 
     </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 

 


Please let us know if you require any other assistance from us. 

Regards, 
Mohanram A. 


Marked as answer

KO Koen February 22, 2021 12:10 PM UTC

Thanks, that helps a lot!


KO Koen replied to Mohanram Anbukkarasu February 22, 2021 02:43 PM UTC

Hi Koen, 

We regret for the inconvenience.  

You can achieve your requirement to select multi values from the dropdown for the collection in the underlying  data object by using GridTemplateColumn with ComboBoxAdv as CellTemplate as shown in the following code example.  

Code example :  

<syncfusion:GridTemplateColumn MappingName="ShipCities"> 
     <syncfusion:GridTemplateColumn.CellTemplate> 
         <DataTemplate> 
             <syncfusion:ComboBoxAdv ItemsSource="{Binding Cities, Source={StaticResource viewModel},UpdateSourceTrigger=PropertyChanged}"  
                                     DisplayMemberPath="ShipCityName"  
                                     SelectedValuePath="ShipCityName" 
                                     AllowMultiSelect="True"  
                                     SelectedItems="{Binding ShipCities, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/> 
         </DataTemplate> 
     </syncfusion:GridTemplateColumn.CellTemplate> 
</syncfusion:GridTemplateColumn> 

 


Please let us know if you require any other assistance from us. 

Regards, 
Mohanram A. 


Hi, thanks for the demo solution. However, I don't get this to work with EF Core using SQL Server... the dropdown itself is populated correctly with the ItemSource, but the SelectedItems are not in sync with the database: it is not displaying correctly and not saving any changes to the database...


MA Mohanram Anbukkarasu Syncfusion Team February 23, 2021 01:43 PM UTC

Hi Koen, 

Thanks for the update.  

We are little unclear with the reported problem and scenario. Kindly provide more details about the ItemsSource you have bounded to the SfDataGrid and the ComboBoxAdv and how you are populating the ItemsSource collections with complete code snippets and also provide the xaml and cs code snippets of creating SfDataGrid and GridTemplateColumn. These details will be more helpful for us to find the exact cause for the reported issue and to provide a prompt solution.  

Regards, 
Mohanram A. 


Loader.
Up arrow icon