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

Styling ChildTable in Hierarchical Grid

3 Answers 215 Views
GridView
This is a migrated thread and some comments may be shown as answers.
JTango
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?

Cheers

Justin

3 Answers, 1 is accepted

Sort by
0
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"
                    <Setter.Value> 
                        <ControlTemplate TargetType="{x:Type telerik:ChildDataControlsPresenter}"
                            <ItemsControl ItemsSource="{Binding}"
                                <ItemsControl.ItemTemplate> 
                                    <DataTemplate> 
                                        <telerik:GridViewDataControl IsHierarchyRoot="False" ColumnsWidthMode="Auto" 
                                                                     ItemsSource="{Binding TableDefinition.DataSource}" 
                                                                     ParentRow="{Binding ParentRow, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:ChildDataControlsPresenter}}}" /> 
                                    </DataTemplate> 
                                </ItemsControl.ItemTemplate> 
                            </ItemsControl> 
                        </ControlTemplate> 
                    </Setter.Value> 
                </Setter> 
            </Style> 

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.
0
BILL
Top achievements
Rank 1
answered on 07 Mar 2013, 11:34 PM
Hello,
  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"
        Width="120"
        VerticalAlignment="Center"
        SelectedIndex="0"
        MaxDropDownHeight="220">
    <telerikControls:Windows8TouchTheme />
    <telerikControls:Windows8Theme  />
    <telerikControls:Windows7Theme />
    <telerikControls:VistaTheme />
    <telerikControls:SummerTheme />
    <telerikControls:Expression_DarkTheme />
    <telerikControls:Office_BlackTheme />
    <telerikControls:Office_BlueTheme />
    <telerikControls:Office_SilverTheme />
    <telerikControls:TransparentTheme />
</telerik:RadComboBox>


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:RadGridView.ChildTableDefinitions>
        <telerik:GridViewTableDefinition  telerikControls:StyleManager.Theme="{Binding SelectedItem, ElementName=ThemeSelector}" >
            <telerik:GridViewTableDefinition.Relation>
                <telerik:PropertyRelation ParentPropertyName="SiteFuelInfoBySites" />
            </telerik:GridViewTableDefinition.Relation>
        </telerik:GridViewTableDefinition>
    </telerik:RadGridView.ChildTableDefinitions>
...
    <telerik:RadGridView.HierarchyChildTemplate>
        <DataTemplate>
            <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" 
                                HorizontalContentAlignment="Stretch">
                    <telerik:RadGridView.Columns>


Any help with this would be great....

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

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.

Tags
GridView
Asked by
JTango
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
BILL
Top achievements
Rank 1
Share this question
or