Styling ChildTable in Hierarchical Grid

4 posts, 0 answers
  1. JTango
    JTango avatar
    24 posts
    Member since:
    Jan 2007

    Posted 30 Nov 2008 Link to this post

    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?


  2. Nedyalko Nikolov
    Nedyalko Nikolov avatar
    871 posts

    Posted 03 Dec 2008 Link to this post

    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.
  3. BILL
    BILL avatar
    4 posts
    Member since:
    Oct 2011

    Posted 07 Mar 2013 Link to this post

      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
  4. Nedyalko Nikolov
    Nedyalko Nikolov avatar
    871 posts

    Posted 11 Mar 2013 Link to this post


    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.

Back to Top