GridComboBoxColumn With DataTable doesn't raise the changes

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


5 Replies 1 reply marked as answer

DM Dhanasekar Mohanraj Syncfusion Team June 23, 2022 02:13 PM UTC

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?

  1. Entire code block related to SfDataGrid both XAML and Code behind 

  2. Share the issue reproducing sample that will help us to analyze and provide solution in shorter time.

  3. 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.



EL Elisa June 24, 2022 04:50 PM UTC

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




EL Elisa June 24, 2022 06:52 PM UTC

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



EL Elisa June 27, 2022 09:43 AM UTC

The problem occurs because, on deserialization, the id column is created as int64 instead of int32.

Now it works, thanks



DM Dhanasekar Mohanraj Syncfusion Team June 27, 2022 02:16 PM UTC

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.


Marked as answer
Loader.
Up arrow icon