This is a migrated thread and some comments may be shown as answers.

Binding the property from the grandson level

1 Answer 310 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Trump
Top achievements
Rank 1
Trump asked on 15 Feb 2019, 01:05 AM

Let's say I have a RadGridView ---first level.(Father)

Then Inside it there is RowDetails DataTemplate in each row  -- second level(Son)

Inside RowDetails template there is also a RadGridView, --- third level. (Grandson)

So in the cell template of the third level, I have a combobox, the itemsSource comes from ViewModel. So how to bind it? 

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 19 Feb 2019, 12:06 PM
Hi Trump,

What you could try is using RelativeSource to bind to the DataContext of the Window which holds the RadGridView (Father). You can set the DataContext of the Window to ViewModel. Then you can bind the RadComboBox inside a CellEditTemplate to your custom collection from the ViewModel using RelativeSource binding.
<telerik:RadGridView x:Name="GrandSon_GridView" ItemsSource="{Binding SonGridView_Collection}" >
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn Width="200">
            <telerik:GridViewDataColumn.CellEditTemplate>
                <DataTemplate>
                    <telerik:RadComboBox ItemsSource="{Binding DataContext.ComboBoxSource,RelativeSource={RelativeSource AncestorType=Window,Mode=FindAncestor}}"/>
                </DataTemplate>
            </telerik:GridViewDataColumn.CellEditTemplate>
        </telerik:GridViewDataColumn>
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Give this approach a try and let me know how it goes.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Trump
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or