Hi,
we want to select a value from ComboBox in a SFDataGrid. I tried it with GridComboboxColumn and GridTemplateColumn + Combobox but both are not selectable with my complex datatype KeyValue. It wont open if I tap on it. If I change the ObservableCollection<KeyValue> to ObservableCollection<string> the GridComboboxColumn is selectable but the GridTemplateColumn + Combobox isn't. How can I get it to work? We prefere the nested combobox instead of GridComboboxColumn because I can't tap out without selecting.
<sfgrid:SfDataGrid x:Name="dgAuftraege"
ItemsSource="{Binding Auftraege}"
AutoGenerateColumns="False"
ColumnSizer="Star"
AllowEditing="True"
SelectionMode="Single"
EditTapAction="OnTap"
NavigationMode="Cell">
<sfgrid:SfDataGrid.Columns>
<sfgrid:GridTextColumn HeaderText="Struktur" CellTextSize="15" MappingName="StrukturId" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Auftrag" CellTextSize="15" MappingName="BelId" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Bezeichnung" CellTextSize="15" MappingName="Matchcode" Width="350" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Sollmenge" CellTextSize="15" MappingName="Sollmenge" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Sollstarttermin" CellTextSize="15" MappingName="Sollendtermin" Format="dd.MM.yyyy" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Sollendtermin" CellTextSize="15" MappingName="Sollendtermin" Format="dd.MM.yyyy" AllowEditing="False"/>
<sfgrid:GridTextColumn HeaderText="Projekt" CellTextSize="15" MappingName="Projekt" AllowEditing="False"/>
<sfgrid:GridComboBoxColumn MappingName="Value" BindingContext="{x:Reference viewModel}" ItemsSource="{Binding MitarbeiterList}" AllowEditing="True" />
<sfgrid:GridTemplateColumn MappingName="CustomerID" AllowEditing="True">
<sfgrid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<combobox:SfComboBox HeightRequest="40" x:Name="comboBox" DataSource="{Binding MitarbeiterList}"/>
</DataTemplate>
</sfgrid:GridTemplateColumn.CellTemplate>
</sfgrid:GridTemplateColumn>
</sfgrid:SfDataGrid.Columns>
</sfgrid:SfDataGrid>
public ObservableCollection<KeyValue> MitarbeiterList { get; set; }
public AuftraegeZuweisenViewModel()
{
Auftraege = new ObservableRangeCollection<FaBeleg>();
MitarbeiterList = new ObservableCollection<KeyValue>();
foreach (var item in Settings.Current.MitarbeiterListe)
{
MitarbeiterList.Add(item.Value);
}
}
public class KeyValue
{
public string Key { get; set; }
public string Value { get; set; }
public KeyValue()
{
}
public KeyValue(string key, string value)
{
Key = key;
Value = value;
}
}
Thanks for your help!
Maria