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

Styling ChildTable in Hierarchical Grid

3 Answers 122 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
JTango asked on 01 Dec 2008, 04:05 AM
Is there a way to provide a different style for the grid generated in a hierarchy. E.g. Can the parent grid use one style, while the child grid uses another?



3 Answers, 1 is accepted

Sort by
Nedyalko Nikolov
Telerik team
answered on 03 Dec 2008, 03:22 PM
Hello JTango,

You can refer to the attached example which shows how to partially change the visual presentation of the child grid modifying the ChildDataControlsPresenter control.

A possible solution might look like this:

<Style TargetType="{x:Type telerik:ChildDataControlsPresenter}"
                <Setter Property="Template"
                        <ControlTemplate TargetType="{x:Type telerik:ChildDataControlsPresenter}"
                            <ItemsControl ItemsSource="{Binding}"
                                        <telerik:GridViewDataControl IsHierarchyRoot="False" ColumnsWidthMode="Auto" 
                                                                     ItemsSource="{Binding TableDefinition.DataSource}" 
                                                                     ParentRow="{Binding ParentRow, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:ChildDataControlsPresenter}}}" /> 

In this example we change the ColumnsWidthMode property of the child grids to "Fill". You can change any
other properties available within the control as well.

If this is not your scenario, please provide us with more information. We will be glad to assist.

Kind regards,
Nedyalko Nikolov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Top achievements
Rank 1
answered on 07 Mar 2013, 11:34 PM
  I am having an issue similar to this post except that I have having issues binding the child datagrid theme to a combobox control....

here is the combobox control

<telerik:RadComboBox x:Name="ThemeSelector"
    <telerikControls:Windows8TouchTheme />
    <telerikControls:Windows8Theme  />
    <telerikControls:Windows7Theme />
    <telerikControls:VistaTheme />
    <telerikControls:SummerTheme />
    <telerikControls:Expression_DarkTheme />
    <telerikControls:Office_BlackTheme />
    <telerikControls:Office_BlueTheme />
    <telerikControls:Office_SilverTheme />
    <telerikControls:TransparentTheme />

I can bind the parent datagrid theme just fine but the child datagrid theme is always static, I want the child datagrids theme to change when the combobox is selected, just like the parents...
<telerik:RadGridView  telerikControls:StyleManager.Theme="{Binding SelectedItem, ElementName=ThemeSelector}"
            Name="Fuel_Tracking_Grid"  CanUserResizeRows="True" AutoGenerateColumns="False"
            EnableRowVirtualization="True" GridLinesVisibility="None"
            HorizontalContentAlignment="Stretch"  ShowGroupPanel="False">
        <telerik:GridViewTableDefinition  telerikControls:StyleManager.Theme="{Binding SelectedItem, ElementName=ThemeSelector}" >
                <telerik:PropertyRelation ParentPropertyName="SiteFuelInfoBySites" />
            <StackPanel Orientation="Vertical"  telerikControls:StyleManager.Theme="{Binding SelectedItem, ElementName=ThemeSelector}" >
                <telerik:RadGridView   x:Name="HierarchicalGridView" telerikControls:StyleManager.Theme="{Binding SelectedItem, ElementName=ThemeSelector}"
                            ShowGroupPanel="False"  AutoGenerateColumns="False" ItemsSource="{Binding Path=SiteFuelInfoByTanks}"
                            CanUserResizeRows="True" EnableRowVirtualization="True" GridLinesVisibility="None" 

Any help with this would be great....

Thank you,
Jeremiah Tatro
Programmer at United Oil
Nedyalko Nikolov
Telerik team
answered on 11 Mar 2013, 01:32 PM

Unfortunately there is a problem when using Binding.ElementName in a data template (there are some problems with the visual tree).
Could you please try to use Binding.RelativeSource option (for example to bind Parent and Child grids themes)?

Kind regards,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Asked by
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Top achievements
Rank 1
Share this question