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

Hierarchical grid view border/padding

6 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Richard asked on 13 Oct 2010, 04:59 PM

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

6 Answers, 1 is accepted

Sort by
0
Accepted
Vanya Pavlova
Telerik team
answered on 14 Oct 2010, 03:28 PM
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
0
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 14 Oct 2010, 03:46 PM
Thank you , that's just what I was looking for!

Richard
0
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 29 Jul 2011, 03:41 PM
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

0
Vanya Pavlova
Telerik team
answered on 29 Jul 2011, 07:13 PM
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 >>

0
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 01 Aug 2011, 10:17 AM
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
0
Vanya Pavlova
Telerik team
answered on 01 Aug 2011, 11:49 AM
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 >>

Tags
GridView
Asked by
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Vanya Pavlova
Telerik team
Richard
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or