SfDataGrid ComboBoxColumn for nested grids

I have a nested table for which I want to show a editable, ComboBox Column. The Itemsource for the ComboBox column is a ObservableCollection property get from ViewModel.
this is my code

<Syncfusion:SfDataGrid
                Name="WallInput"
                AllowDeleting="True"
                AllowEditing="True"
                AllowResizingColumns="True"
                AllowResizingHiddenColumns ="True"
                AutoGenerateColumns="False"
                ColumnSizer="Auto"
                EditTrigger="OnTap"
                SelectionUnit="Row"
                ItemsSource="{Binding Beams}"
                SelectedItem="{Binding SelectedBeam}">
                <Syncfusion:SfDataGrid.Resources>
                    <Style TargetType="TextBox"/>
                    <Style TargetType="ComboBox" BasedOn="{StaticResource MahApps.Styles.ComboBox}"/>
                </Syncfusion:SfDataGrid.Resources>
                <Syncfusion:SfDataGrid.Columns>
                    <Syncfusion:GridTextColumn HeaderText="ID"
                                               MappingName="Id"/>
                    <Syncfusion:GridTextColumn HeaderText="Name"
                                               MappingName="Name"/>
                    <Syncfusion:GridComboBoxColumn HeaderText="Engineer Reference"
                                                   MappingName="EngineerMemberInfo"
                                                   ItemsSource="{Binding JobModel.EngineerMemberList}"
                                                   DisplayMemberPath="EngineerName"/>
                    <Syncfusion:GridTextColumn HeaderText="Size Grade"
                                               MappingName="EngineerMemberInfo.RealSizeGrade"
                                               IsReadOnly="True"/>
                    <Syncfusion:GridTextColumn HeaderText="Span Length"
                                               MappingName="SpanLength"/>
                    <Syncfusion:GridTextColumn HeaderText="Extra Length"
                                               MappingName="ExtraLength"/>
                    <Syncfusion:GridTextColumn HeaderText="Quote Length"
                                               MappingName="QuoteLength"/>
                    

                </Syncfusion:SfDataGrid.Columns>

                <syncfusion:SfDataGrid.DetailsViewDefinition>
                    <syncfusion:GridViewDefinition RelationalColumn="LoadPointSupports">
                        <syncfusion:GridViewDefinition.DataGrid>
                            <syncfusion:SfDataGrid AllowDeleting="True"
                                                   AllowEditing="True"
                                                   AllowResizingColumns="True"
                                                   AllowResizingHiddenColumns ="True"
                                                   AutoGenerateColumns="False"
                                                   ColumnSizer="Auto"
                                                   EditTrigger="OnTap"
                                                   SelectionUnit="Row">
                                <Syncfusion:SfDataGrid.Resources>
                                    <Style TargetType="TextBox"/>
                                    <Style TargetType="ComboBox" BasedOn="{StaticResource MahApps.Styles.ComboBox}"/>
                                </Syncfusion:SfDataGrid.Resources>
                                <Syncfusion:SfDataGrid.Columns>
                                    <Syncfusion:GridComboBoxColumn HeaderText="Support Type"
                                                                   MappingName="PoinSupportType"
                                                                   ItemsSource="{Binding Source={StaticResource SupportTypes}}"/>
                                    <Syncfusion:GridTextColumn HeaderText="Point Location"
                                                                   MappingName="PointLocation"
                                                                   IsReadOnly="True"/>
                                   
<Syncfusion:GridComboBoxColumn HeaderText="Reference Name"
                                                                   MappingName="TimberInfo"
                                                                   ItemsSource="{Binding JobModel.EngineerMemberList}"
                                                                   DisplayMemberPath="EngineerName"/>
                                    <Syncfusion:GridTextColumn HeaderText="Size Grade"
                                                               MappingName="EngineerMemberInfo.RealSizeGrade"
                                                               IsReadOnly="True"/>
                                    
                                </Syncfusion:SfDataGrid.Columns>
                            </syncfusion:SfDataGrid>
                        </syncfusion:GridViewDefinition.DataGrid>
                    </syncfusion:GridViewDefinition>
                </syncfusion:SfDataGrid.DetailsViewDefinition>
            </Syncfusion:SfDataGrid>

how i can get dropdown list from GridComboBoxColumn Itemsoure JobModel.EngineerMemberList from i highlighted above, it is empty.
Sorry for my english skill
John

3 Replies 1 reply marked as answer

VS Vijayarasan Sivanandham Syncfusion Team August 7, 2020 02:05 PM UTC

Hi Nguyen,

Thank you for contacting Syncfusion support.

Based on provided information we have prepared the sample for achieve your requirement. Please refer the below code snippet, 
Code snippet C#:  ComboBox column model class.  
   
public class ItemDetails : INotifyPropertyChanged   
{   
    private string itemCode;   
   
    public string ItemCode   
    {   
        get   
        {   
            return itemCode;   
        }   
        set   
        {   
            itemCode = value;   
            RaisePropertyChanged("ItemCode");   
        }   
    }   
    private string itemName;   
   
    public string ItemName   
    {   
        get   
        {   
            return itemName;   
        }   
        set   
        {   
            itemName = value;   
            RaisePropertyChanged("ItemName");   
        }   
    }   
    private int itemID;   
   
    public int ItemID   
    {   
        get   
        {   
            return itemID;   
        }   
        set   
        {   
            itemID = value;   
            RaisePropertyChanged("ItemID");   
        }   
    }   
}   
   
Code snippet C#: Nested data grid model class that has SelName property.   
   
public class OrderDetails:INotifyPropertyChanged   
{   
    private string selName;   
    public string SelName   
    {   
        get   
        {   
            return selName;   
        }   
        set   
        {   
            selName = value;   
            RaisePropertyChanged("SelName");   
        }   
    }   
}   
   
Code snippet C#: Combo box ItemsSource population.  
  
public void PopulateItemDetails()   
{   
    itemDetails = new ObservableCollection<ItemDetails>();   
    itemDetails.Add(new ItemDetails() { ItemName = "SfDatagrid", ItemID = 01, ItemCode = "AAA" });   
    itemDetails.Add(new ItemDetails() { ItemName = "SfCellGrid", ItemID = 02, ItemCode = "AAB" });   
    itemDetails.Add(new ItemDetails() { ItemName = "SfComnboBox", ItemID = 03, ItemCode = "AAC"});   
    itemDetails.Add(new ItemDetails() { ItemName = "SfTreeGrid", ItemID = 04, ItemCode = "AAD" });    
}   
private ObservableCollection<ItemDetails> itemDetails;   
   
public ObservableCollection<ItemDetails> ItemDetails   
{   
    get   
    {   
        return itemDetails;   
    }   
    set   
    {   
        itemDetails = value;   
    }   
}           
    
Code snippet XAML: GridComboBoxColumn binding  
   
<Window.Resources>   
        <local:ViewModel x:Key="viewModel"/>   
    </Window.Resources>   
  
 <syncfusion:SfDataGrid x:Name="dataGrid" Grid.Column="0"   
                        AutoGenerateColumns="False" AllowEditing="True"   
                        AutoGenerateRelations="False"   
                        AllowResizingColumns="False"   
                        HideEmptyGridViewDefinition="True"   
                        ItemsSource="{Binding Path=OrdersDetails}"   
                        NavigationMode="Cell"   
                        ShowGroupDropArea="True">   
    <syncfusion:SfDataGrid.DetailsViewDefinition>   
        <syncfusion:GridViewDefinition RelationalColumn="OrderDetails">   
            <syncfusion:GridViewDefinition.DataGrid>   
                <syncfusion:SfDataGrid x:Name="FirstDetailsViewGrid" AllowEditing="True" >   
                    <syncfusion:SfDataGrid.Columns>   
                    <syncfusion:GridComboBoxColumn ItemsSource="{Binding ItemDetails,Source={StaticResource viewModel}}"    
                                                MappingName="SelName"     
                                                DisplayMemberPath="ItemName"    
                                                SelectedValuePath="ItemName" />   
                   </syncfusion:SfDataGrid.Columns>   
                </syncfusion:SfDataGrid>  
             </syncfusion:GridViewDefinition.DataGrid>  
          <syncfusion:GridViewDefinition >  
     </syncfusion:SfDataGrid.DetailsViewDefinition>                       
</syncfusion:SfDataGrid>  
We hope this helps. Please let us know, if you require further assistance on this.

Regards,
Vijayarasan S 


Marked as answer

ND Nour Douffir April 6, 2022 01:37 PM UTC

Hello,

I was able to use this approach to bind a comboboxcolumn in a nested datagrid. However, I am running into a problem where once the combobox is loaded and the itemsource is modified, the combobox does not reflect the changes made. 

Thank You,

Nour



VS Vijayarasan Sivanandham Syncfusion Team April 7, 2022 04:02 PM UTC

Hi Nour Douffir,


We are a little unclear about your reported issue. Please provide more information related to your query?

  • Confirm whether the modified itemsource is bound with SfDataGrid or not
  • Confirm whether the modified itemsource is bound with ComboBox or not
  • Details about your scenario with image illustrations?
  • Video illustration of the issue

Kindly revert to us with the above requested details. It will be more helpful for us to check the possibilities to resolve the reported problem.


Regards,

Vijayarasan S


Loader.
Up arrow icon