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

RadDataGridView with Toolbar...

3 Answers 121 Views
GridView
This is a migrated thread and some comments may be shown as answers.
YoungKee
Top achievements
Rank 1
YoungKee asked on 27 Jun 2016, 04:07 AM

Hi everyone,

I want to make a control radDataGridView with toolbar not user control

In toolbar, buttons located like add/edit/delete/show group panel...etc.

how do i make it ?

thanks for your interest.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 29 Jun 2016, 09:06 AM
Hello YoungKee,

Your custom control should simply inherit from RadGridView and you will additionally need to predefine its control template, basing the style on the default RadGridView style, following the approach described here. For your convenience, I've prepared the following style:

<Style TargetType="local:CustomRadGrid" BasedOn="{StaticResource RadGridViewStyle}">
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="local:CustomRadGrid">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition Width="0"/>
                        <ColumnDefinition Width="Auto"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <StackPanel Orientation="Horizontal">
                        <Button Content="Add" Command="controls:RadGridViewCommands.BeginInsert" />
                        <Button Content="Edit" Command="controls:RadGridViewCommands.BeginEdit"/>
                        <Button Content="Delete" Command="controls:RadGridViewCommands.Delete" />
                    </StackPanel>
                    <telerik:GridViewSearchPanel x:Name="PART_SearchPanel" Background="{TemplateBinding SearchPanelBackground}" Grid.ColumnSpan="3" Foreground="{TemplateBinding SearchPanelForeground}" Grid.Row="1" IsTabStop="False">
                        <telerik:GridViewSearchPanel.Visibility>
                            <Binding Path="ShowSearchPanel" RelativeSource="{RelativeSource TemplatedParent}">
                                <Binding.Converter>
                                    <telerik:BooleanToVisibilityConverter/>
                                </Binding.Converter>
                            </Binding>
                        </telerik:GridViewSearchPanel.Visibility>
                    </telerik:GridViewSearchPanel>
                    <telerik:GridViewGroupPanel x:Name="PART_GroupPanel" Background="{TemplateBinding GroupPanelBackground}" Grid.ColumnSpan="3" Foreground="{TemplateBinding GroupPanelForeground}" IsTabStop="False" Grid.Row="2"/>
                    <Border x:Name="PART_MasterGridContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="3" Margin="0,-1,0,0" Padding="{TemplateBinding Padding}" Grid.Row="2"/>
                    <ItemsControl x:Name="PART_ControlPanelItemsControl" Grid.Column="2" HorizontalAlignment="Right" Grid.Row="1">
                        <ItemsControl.ItemsPanel>
                            <ItemsPanelTemplate>
                                <StackPanel IsItemsHost="True" Orientation="Horizontal"/>
                            </ItemsPanelTemplate>
                        </ItemsControl.ItemsPanel>
                        <ItemsControl.ItemTemplate>
                            <DataTemplate>
                                <telerik:ControlPanelItemControl/>
                            </DataTemplate>
                        </ItemsControl.ItemTemplate>
                    </ItemsControl>
                    <telerik:GridViewScrollViewer x:Name="PART_ItemsScrollViewer" CanContentScroll="True" Grid.ColumnSpan="3" Margin="1,0,1,1" Grid.Row="3" Grid.RowSpan="2">
                        <telerik:GridViewScrollViewer.FooterRow>
                            <telerik:GridViewFooterRow x:Name="PART_FooterRow" IsTabStop="False" IndentLevel="{TemplateBinding GroupCount}"/>
                        </telerik:GridViewScrollViewer.FooterRow>
                        <telerik:GridViewScrollViewer.HeaderRow>
                            <telerik:GridViewHeaderRow x:Name="PART_HeaderRow" IsTabStop="False" IndentLevel="{TemplateBinding GroupCount}"/>
                        </telerik:GridViewScrollViewer.HeaderRow>
                        <telerik:GridViewScrollViewer.NewRow>
                            <telerik:GridViewNewRow x:Name="PART_AddNewRow" IsTabStop="False" IndentLevel="{TemplateBinding GroupCount}"/>
                        </telerik:GridViewScrollViewer.NewRow>
                        <telerik:GridViewVirtualizingPanel x:Name="PART_GridViewVirtualizingPanel" CanHorizontallyScroll="True" CanVerticallyScroll="True"/>
                    </telerik:GridViewScrollViewer>
                    <telerik:ScrollPositionIndicator x:Name="PART_ScrollPositionIndicator" Grid.ColumnSpan="3" ContentTemplate="{TemplateBinding ScrollPositionIndicatorTemplate}" HorizontalAlignment="Right" IsHitTestVisible="False" IsTabStop="False" Margin="0,0,28,0" Grid.Row="3">
                        <telerik:ScrollPositionIndicator.Visibility>
                            <Binding Mode="TwoWay" Path="IsScrolling" RelativeSource="{RelativeSource TemplatedParent}">
                                <Binding.Converter>
                                    <telerik:BooleanToVisibilityConverter/>
                                </Binding.Converter>
                            </Binding>
                        </telerik:ScrollPositionIndicator.Visibility>
                    </telerik:ScrollPositionIndicator>
                    <Border x:Name="PART_FrozenColumnsPreview" Background="{DynamicResource {x:Static telerik:GreenResourceKey.AccentLowBrush}}" HorizontalAlignment="Left" Opacity="0.1" Grid.Row="3" Grid.RowSpan="3" Visibility="Collapsed" VerticalAlignment="Stretch" Width="6">
                        <Border BorderBrush="{DynamicResource {x:Static telerik:GreenResourceKey.AccentLowBrush}}" BorderThickness="1,0,0,0" HorizontalAlignment="Right" Width="5"/>
                    </Border>
                    <telerik:GridViewLoadingIndicator x:Name="PART_GridViewLoadingIndicator" Grid.ColumnSpan="3" IsTabStop="False" IsBusy="{TemplateBinding IsBusy}" Grid.RowSpan="3" Visibility="Collapsed"/>
                </Grid>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsBusy" Value="True">
                        <Setter Property="Visibility" TargetName="PART_GridViewLoadingIndicator" Value="Visible"/>
                    </Trigger>
                    <Trigger Property="ShowColumnFooters" Value="False">
                        <Setter Property="Visibility" TargetName="PART_FooterRow" Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="ShowColumnHeaders" Value="False">
                        <Setter Property="Visibility" TargetName="PART_HeaderRow" Value="Collapsed"/>
                    </Trigger>
                    <Trigger Property="ShowGroupPanel" Value="False">
                        <Setter Property="Visibility" TargetName="PART_GroupPanel" Value="Collapsed"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

This will enable Insert, and Remove functionality through the buttons in the stack panel. Of course, you can bind any available command RadGridView exposes.

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dilyan Traykov
Telerik team
answered on 29 Jun 2016, 09:09 AM
Hello,

Here's the controls namespace from the previous reply:

xmlns:controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"

and the one:


Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
YoungKee
Top achievements
Rank 1
answered on 29 Jun 2016, 10:18 AM
Thanks for your help. i will try it.
Tags
GridView
Asked by
YoungKee
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
YoungKee
Top achievements
Rank 1
Share this question
or