Hierarchical grid view border/padding

7 posts, 1 answers
  1. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 13 Oct 2010 Link to this post

    Hopefully this is a quick one.  I have a hierarchical grid view and when I expand the child grid there is a border/padding around it of about 5 pixels. How do I set this to 0 so there is no space around the child grid ?

     

    Thanks,

    Richard

  2. Answer
    Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 14 Oct 2010 Link to this post

    Hello Richard,

    You can easily achieve this effect through editing the template of GridViewRow, find HierarchyChildPresenter and set the Padding property of the Border that holds it to 0. If you want to read more about styles and templates I would suggest you to see the following article Styling a Row. Attached is a sample project that illustrates this approach.

    If you need any further assistance please let me know.

    Greetings,
    Vanya Pavlova
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
  4. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 14 Oct 2010 Link to this post

    Thank you , that's just what I was looking for!

    Richard
  5. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 29 Jul 2011 Link to this post

    I have been using this method to control the padding of the sub items in my grid and it works. However I have applied a theme to the grid with an alternating row style. The padding is not getting applied to every second record.
    Seems straight forward enough, edit the alternating row template to include the padding = 0 as well but it does not work.

    Blend will not let me create a RowStyle and AltRowStyle copy of the templates because of a "Resource Key Conflict" . 

    So my question is , using the HierarchyChildPresenter's Padding = 0 how can I make this work with alternating row styles ?? 

    Thanks,
    Richard

  6. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Jul 2011 Link to this post

    Hi Richard,

     
    If you want to remove the Padding in these styles you should have 2 separate templates-one for the ordinary GridViewRowStyle and the second one for AlternateRowStyle. Both are targeted at GridViewRow. 
    Indeed you may get a resource conflicts if these styles are in a common ResourceCollection,  so you may do the following:

    1. Add two separate ResourceDictionaries to your project - ResourceDictionary1, ResourceDictionary2.
    2. In ResourceDictionary1 copy the template from my previous reply and name it GridViewRowStyle1.
    3. In ResourceDictionary2 copy the template from my previous reply and name it AlternateRowStyle1.

    Set these styles to RadGridView and you will remove the Padding in a Hierarchical RadGridView in both cases.


    Please give it a try and let me know how it goes!

    Regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

  7. Richard
    Richard avatar
    72 posts
    Member since:
    Feb 2009

    Posted 01 Aug 2011 Link to this post

    Hi Vanya,

    I'm starting to get other issues now, as the applications theme can be set by  the user the active theme when I create the template in Blend is not necessarily the  going to match the theme for the end user. 
    This has resulted in the parent grid having a different theme to the child grid.

    Is there a way to access this property in code so I would just be modifying the padding and nothing else ?

    Thanks
    Richard
  8. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 01 Aug 2011 Link to this post

    Hi Richard,

     
    This Padding is hard-coded within the template of GridViewRow. You may remove it only through editing the template of this element. Keep in mind that styles in Telerik themes are theme specific. If you want to set an AlternateRowStyle (or any other style such as CellStyle, HeaderCellStyle etc.) to child tables you may mark the style as BasedOn the particular theme:


    <UserControl.Resources>
      
        <Style x:Key="s1" TargetType="telerik:GridViewRow" telerik:StyleManager.BasedOn="Vista">
      
            <Setter Property="Foreground" Value="Red"/>
     ........
        </Style>
      
        </UserControl.Resources>
      
        <Grid x:Name="LayoutRoot" Background="White">
     
      
        </Grid>
      
    </UserControl>


    Then when you set Vista theme the style above will be handled correspondingly.
    You may use the same technique for any RadControl if you need to make some changes based on a theme different than the default one. 



    Kind regards,
    Vanya Pavlova
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

Back to Top
DevCraft banner