|
<syncfusion:GridTemplateColumn MappingName="Country">
<syncfusion:GridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Country}" />
</DataTemplate>
</syncfusion:GridTemplateColumn.CellTemplate>
<syncfusion:GridTemplateColumn.EditTemplate>
<DataTemplate>
<ComboBox SelectedItem="{Binding Country, Mode=TwoWay}">
<ComboBox.ItemsSource>
<CompositeCollection>
<ComboBoxItem IsEnabled="False" Content=""/>
<CollectionContainer Collection="{Binding Source={StaticResource ComboBoxItems}}" />
</CompositeCollection>
</ComboBox.ItemsSource>
</ComboBox>
</DataTemplate>
</syncfusion:GridTemplateColumn.EditTemplate>
</syncfusion:GridTemplateColumn> |
|
Query |
Solution | |
|
This works correctly but has no additional item:
<sync:GridComboBoxColumn HorizontalHeaderContentAlignment="Left" MappingName="User" Width="150">
<sync:GridComboBoxColumn.ItemsSource>
<Binding Path="UserList.Items"/>
</sync:GridComboBoxColumn.ItemsSource>
</sync:GridComboBoxColumn>
This does not work, it only adds the "AdditionalItem" and fails to add my UserList.Items:
<sync:GridComboBoxColumn HorizontalHeaderContentAlignment="Left" MappingName="User" Width="150">
<sync:GridComboBoxColumn.ItemsSource>
<CompositeCollection>
<ComboBoxItem IsEnabled="True" Content="AdditionalItem" />
<CollectionContainer Collection="{Binding UserList.Items}" />
</CompositeCollection>
</sync:GridComboBoxColumn.ItemsSource>
</sync:GridComboBoxColumn>
Why does the CompositeCollection not work?
|
You should not bind the items source collection to the CollectionContainer. You have to make use of the CollectionViewSource as shown in the following code example.
Code example:
| |
|
also, i need to be able to select the blank item to deselect all values |
This can be achieved by creating a custom combo box cell render as shown in the following code example.
Code example :
Sample link : https://www.syncfusion.com/downloads/support/forum/159891/ze/SfDataGrid_GridComboBoxColumn_BlankItem-2049018761
| |
|
I would like to request that you add 2 properties to GridComboBoxColumn
AddBlankItem="True"
CanSelectBlankItem="True"
or
CanDeselect="True" |
We have forwarded this query to our development team for analysis. We will update with further details on 25th November 2020. We appreciate your patience until then.
|
Mohanram,
Thanks
for your follow up.
Scenario
1:
There
are scenarios where you want a blank item to be selected by default in your grid combobox. Once they have selected an actual item from the list in your comobox, they SHOULD NOT be able to select that
blank item again.
Scenario
2:
There are other scenarios where you want a blank item to be selected by default in your grid combo box. Once they have selected an actual item from the list in your combobox, they SHOULD be able to select that blank item again. If they select the blank item, it sets the mapped property to null.
Let me
know if you need additional clarification.
Thanks,
Carlin