I have a master-detail structure where in TableMaster there is the foreign key and in ComboBoxItemsSource there are the key and relative value:
public List<ComboBoxElement> ComboBoxItemsSource { get; set; }public ObservableCollection<TableElement> TableMaster { get; set; }
public class TableElement
{
public int foreignId { get; set; }
}
public class ComboBoxElement
{
public int Id { get; set; }
public string Value { get; set; }
}
Here is the xaml:
<syncfusion:SfDataGrid
AllowEditing="True"
AutoGenerateColumns="False"
ItemsSource="{Binding TableMaster}>
<syncfusion:SfDataGrid.Columns>
<syncfusion:GridComboBoxColumn
HeaderText=" Foreign Id "
ItemsSource="{Binding ComboBoxItemsSource}"
MappingName="foreignId"
SelectedValuePath="Id"
DisplayMemberPath="Value"/>
</syncfusion:SfDataGrid.Columns>
</syncfusion:SfDataGrid>
In this case everything works correctly, but if I use DataTable as TableMaster instead of ObservableCollection, the value in the cell doesn't show and it doesn't change
Hi Elisa,
We regret to let you know that the provided details are not enough to replicate the reported issue in our end. Can you please share us below things?
Entire code block related to SfDataGrid both XAML and Code behind
Share the issue reproducing sample that will help us to analyze and provide solution in shorter time.
Share the video illustration for the reported issue
It will be helpful for us to check on it and provide you the solution at the earliest.
Regards,
Dhanasekar M.
I created a small example project containing just the view with the sfDataGrid and the viewmodel with its ItemSource which is a DataTable:
https://drive.google.com/file/d/1_GMyYdjfphtHdoU8_eS7TELcJN8Q4Bui/view?usp=sharing
If I fill the
ItemSource in the viewmodel constructor, the view show the results in the grid, but if I fill the
ItemSource after the view is loaded, as in this case, the view doesn't show nothing
Sorry, I realized my viewmodel didn't implement INotifyPropertyChanged, my fault. Now the grid is populated, but I still have a problem, if the DataTable is generated from a deserialized json, the grid doesn't show the values
Here the sample:
https://drive.google.com/file/d/1ruoKOiNmLP3i7UyZvN0egu66p8DQqRJK/view?usp=sharing
The problem occurs because, on deserialization, the id column is created as int64 instead of int32.
Now it works, thanks
Hi Elisa,
We are glad to know the reported
issue resolved in your end. Please let us know if you have any further queries
on this. Otherwise please mark it as an answer. We are happy to help you.
Regards,
Dhanasekar M.