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

RadGridView Style

6 Answers 97 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ghasem
Top achievements
Rank 1
Ghasem asked on 23 Jul 2014, 06:10 AM
Hi

I’m using RadGridView in my application. I have set style of Template Property of GridView with Blend.

The problem is that GroupPanel and GroupFooter are shown even after I have set:

radGridView1.ShowGroupFooters = false;

radGridView1.ShowGroupPanel= false;

 
Is there anything wrong with my
style?

The following is my style:

    <Style x:Key="CustomGridViewStyle" TargetType="{x:Type telerik:RadGridView}" BasedOn="{StaticResource ResourceKey=RadGridViewStyle}">

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="telerik:RadGridView">

                    <Grid>

                        <Grid.RowDefinitions>

                            <RowDefinition/>

                            <RowDefinition Height="auto"/>

                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0">

                            <VisualStateManager.VisualStateGroups>

                                <VisualStateGroup x:Name="GridViewActivity">

                                    <VisualState x:Name="Idle">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_GridViewLoadingIndicator" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Collapsed</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                    <VisualState x:Name="Busy">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_GridViewLoadingIndicator" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                    <DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Visible</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                                </DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                                <VisualStateGroup x:Name="ColumnHeadersVisibility">

                                    <VisualState x:Name="ColumnHeadersVisible">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_HeaderRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                    <DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Visible</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                                </DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                    <VisualState x:Name="ColumnHeadersCollapsed">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_HeaderRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                               
        <Visibility>Collapsed</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                                <VisualStateGroup x:Name="ColumnFootersVisibility">

                                    <VisualState x:Name="ColumnFootersVisible">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_FooterRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                               
        <Visibility>Visible</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                    <VisualState x:Name="ColumnFootersCollapsed">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_FooterRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                    <DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Collapsed</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                                <VisualStateGroup x:Name="GroupPanelVisibility">

                                    <VisualState x:Name="GroupPanelVisible">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_GroupPanel" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                    <DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Visible</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                    <VisualState x:Name="GroupPanelCollapsed">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_GroupPanel" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Collapsed</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                                <VisualStateGroup x:Name="InsertRowVisibility">

                                    <VisualState x:Name="InsertRowVisible">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_AddNewRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                                
       <Visibility>Visible</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                    <VisualState x:Name="InsertRowCollapsed">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_AddNewRow" Storyboard.TargetProperty="Visibility">

                                               
<DiscreteObjectKeyFrame KeyTime="0">

                                                    <DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Collapsed</Visibility>

                                                   
</DiscreteObjectKeyFrame.Value>

                                                </DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                                <VisualStateGroup x:Name="DisabledStates">

                                    <VisualState x:Name="Enabled"/>

                                    <VisualState x:Name="Disabled">

                                        <Storyboard>

                                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="Background_Disabled" Storyboard.TargetProperty="Visibility">

                                                <DiscreteObjectKeyFrame KeyTime="0">

                                                   
<DiscreteObjectKeyFrame.Value>

                                                       
<Visibility>Visible</Visibility>

                                                    </DiscreteObjectKeyFrame.Value>

                                               
</DiscreteObjectKeyFrame>

                                            </ObjectAnimationUsingKeyFrames>

                                        </Storyboard>

                                    </VisualState>

                                </VisualStateGroup>

                            </VisualStateManager.VisualStateGroups>

                            <Grid.RowDefinitions>

                                <RowDefinition Height="Auto"/>

                                <RowDefinition x:Name="PART_AttachedBehaviorRow" Height="Auto"/>

                                <RowDefinition/>

                                <RowDefinition x:Name="ScrollBarRow" MinHeight="0" Height="0"/>

                                <RowDefinition Height="Auto"/>

                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>

                                <ColumnDefinition/>

                                <ColumnDefinition x:Name="ScrollBarColumn"
MinWidth="0" Width="0"/>

                                <ColumnDefinition Width="Auto"/>

                            </Grid.ColumnDefinitions>

                            <telerik:GridViewGroupPanel x:Name="PART_GroupPanel"

                    Grid.ColumnSpan="3"

                    Visibility="{TemplateBinding Visibility}"

                    Background="{TemplateBinding GroupPanelBackground}"

                    Foreground="{TemplateBinding GroupPanelForeground}"

                    BorderBrush="{StaticResource GridView_GroupPanelOuterBorder}"/>

                            <ItemsControl x:Name="PART_ControlPanelItemsControl" Grid.Column="2" IsTabStop="False" HorizontalAlignment="Right">

                                <ItemsControl.ItemsPanel>

                                    <ItemsPanelTemplate>

                                        <StackPanel Orientation="Horizontal"/>

                                    </ItemsPanelTemplate>

                                </ItemsControl.ItemsPanel>

                                <ItemsControl.ItemTemplate>

                                    <DataTemplate>

                                        <telerik:ControlPanelItemControl />

                                    </DataTemplate>

                                </ItemsControl.ItemTemplate>

                            </ItemsControl>

                            <Border

                    Name="PART_MasterGridContainer"

                    Grid.Row="2"

                    Grid.RowSpan="2"

                    Grid.ColumnSpan="3"

                    Background="{TemplateBinding Background}"

                    Margin="0,-1,0,0"

                    BorderBrush="{TemplateBinding BorderBrush}"

                    BorderThickness="{TemplateBinding BorderThickness}"

                    Padding="{TemplateBinding Padding}"/>

                            <telerik:GridViewScrollViewer x:Name="PART_ItemsScrollViewer"

                    Background="Transparent"

                    CanContentScroll="True"

                    Grid.Row="2"

                    Grid.RowSpan="2"

                    Grid.ColumnSpan="3"

                    Margin="1,0,1,1">

                                <telerik:GridViewScrollViewer.HeaderRow>

                                    <telerik:GridViewHeaderRow x:Name="PART_HeaderRow" IndentLevel="{TemplateBinding
GroupCount}"
Visibility="{TemplateBinding Visibility}"/>

                                </telerik:GridViewScrollViewer.HeaderRow>

                                <telerik:GridViewScrollViewer.NewRow>

                                    <telerik:GridViewNewRow Name="PART_AddNewRow" IndentLevel="{TemplateBinding
GroupCount}"
Visibility="{TemplateBinding Visibility}"/>

                                </telerik:GridViewScrollViewer.NewRow>

                                <telerik:GridViewScrollViewer.FooterRow>

                                    <telerik:GridViewFooterRow x:Name="PART_FooterRow" IndentLevel="{TemplateBinding
GroupCount}"
Visibility="{TemplateBinding Visibility}"/>

                                </telerik:GridViewScrollViewer.FooterRow>

                                <telerik:GridViewVirtualizingPanel x:Name="PART_GridViewVirtualizingPanel"/>

                            </telerik:GridViewScrollViewer>

                            <telerik:ScrollPositionIndicator x:Name="PART_ScrollPositionIndicator"

                    Margin="0,0,28,0"

                    IsHitTestVisible="False"

                    HorizontalAlignment="Right"

                    Grid.Row="2"

                    Grid.ColumnSpan="3"

                    Visibility="{Binding IsScrolling, Mode=TwoWay, RelativeSource={RelativeSource
TemplatedParent}, Converter={StaticResource
BooleanToVisibilityConverter}}"

                    ContentTemplate="{TemplateBinding ScrollPositionIndicatorTemplate}"/>

                            <Border x:Name="PART_FrozenColumnsPreview"

                    Grid.Row="1"

                    Visibility="Collapsed"

                    HorizontalAlignment="Left"

                    VerticalAlignment="Stretch"

                    Grid.RowSpan="4"

                    Background="#33000000"

                    Width="6"/>

                            <telerik:GridViewLoadingIndicator x:Name="PART_GridViewLoadingIndicator"

                    Visibility="Collapsed"

                    IsBusy="{Binding IsBusy, Mode=TwoWay, RelativeSource={RelativeSource
TemplatedParent}}"

                    Grid.RowSpan="4"

                    Grid.ColumnSpan="3"/>

                            <Rectangle x:Name="Background_Disabled" Fill="{StaticResource
Background_Disabled}" IsHitTestVisible="False" Grid.RowSpan="5" Grid.ColumnSpan="3" Visibility="Collapsed"/>

                        </Grid>

                        <Grid Grid.Row="1"

                           
<telerik:RadButton Width="50" content="Click"/>

                        </Grid>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>

 

6 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 23 Jul 2014, 12:33 PM
Hi Ghasem,


I've modfied your style and wrap it in a runnable solution, that you could test by your side. 

Hope this helps. 

Regards,
Vanya Pavlova
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ghasem
Top achievements
Rank 1
answered on 28 Jul 2014, 08:06 AM
Thank you for your help. I have another question that you might help me, I want to add a button below the grid view template. Plz help me do it.
0
Vanya Pavlova
Telerik team
answered on 28 Jul 2014, 08:11 AM
Hi Ghasem,


Thank you for getting back to us.

What should be the purpose of this button within the template of RadGridView?  


Regards,
Vanya Pavlova
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ghasem
Top achievements
Rank 1
answered on 28 Jul 2014, 09:47 AM
For example I want to insert a TextBlock in GridView Template that shows count of rows of GridView.
0
Accepted
Vanya Pavlova
Telerik team
answered on 28 Jul 2014, 10:26 AM
Hi Ghasem,


Thank you for getting back to us. 

You could use Aggregate Functions to display total number of items in RadGridView. Another approach would be to predefine the tempplate of RadGridView and place a TextBlock elements and bind its Text property to the Items.Count of the grid. 

I'm attaching you small sample demo, which illustrates how to achieve your goal. 


Regards,
Vanya Pavlova
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Ghasem
Top achievements
Rank 1
answered on 03 Aug 2014, 07:27 AM
Thank you.I Really appreciate your help.
Tags
GridView
Asked by
Ghasem
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Ghasem
Top achievements
Rank 1
Share this question
or