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

[Solved] Hierarchical Element

3 Answers 128 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Hazeest
Top achievements
Rank 1
Hazeest asked on 28 Oct 2009, 03:33 PM
How can I get access to the item in hierarchical grid?
<UserControl 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input" xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" x:Class="linnworks.cloud.component.stockcontrol.Inventory.ctrInventory" MinWidth="600" MinHeight="300"
    <UserControl.Resources> 
        <DataTemplate x:Key="GridHierarchy"
            <Grid Width="Auto" HorizontalAlignment="Stretch" Background="White"
                <Grid.RowDefinitions> 
                    <RowDefinition /> 
                    <RowDefinition /> 
                </Grid.RowDefinitions> 
                 
                <telerikNavigation:RadTabControl Grid.Row="0"
                    <telerikNavigation:RadTabItem Margin="10,0,0,0" Height="24" FontWeight="Bold" FontSize="11" Foreground="Black"
                        <telerikNavigation:RadTabItem.Header> 
                            <StackPanel Orientation="Horizontal"
                                <Image Source="/linnworks.cloud.component.stockcontrol;Component/Images/eraser.png" Width="16" /> 
                                <TextBlock Text=" Properties" /> 
                            </StackPanel> 
                        </telerikNavigation:RadTabItem.Header> 
                        <Border BorderBrush="#FF000000" BorderThickness="0" Margin="0,0,0,0"
                            <Grid Width="Auto" HorizontalAlignment="Stretch" Background="White"
                                <Grid.RowDefinitions> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition /> 
                                    <RowDefinition  Height="16"/> 
                                </Grid.RowDefinitions> 
                                <Grid.ColumnDefinitions> 
                                    <ColumnDefinition Width="0" /> 
                                    <ColumnDefinition Width="Auto" /> 
                                    <ColumnDefinition Width="Auto" /> 
                                </Grid.ColumnDefinitions> 
 
 
                                <TextBlock Text="Item #: " Margin="48,26,0,0" FontWeight="Bold" Grid.Row="1" Grid.Column="1" /> 
                                <TextBox Text="{Binding ItemNumber}" Margin="48,26,0,0" Grid.Row="1" Grid.Column="2" /> 
                                <TextBlock Text="Title: " Margin="48,0,0,0" FontWeight="Bold" Grid.Row="2" Grid.Column="1" /> 
                                <TextBox Text="{Binding ItemTitle}" Margin="48,0,0,0" Grid.Row="2" Grid.Column="2" /> 
                                <TextBlock Text="Category: " Margin="48,0,0,0" FontWeight="Bold" Grid.Row="3" Grid.Column="1" /> 
                                <telerikInput:RadComboBox x:Name="inventory_hierCategory" Margin="48,0,0,0" IsEditable="True" IsReadOnly="True" Grid.Row="3" Grid.Column="2" Foreground="#FF000000" Width="300"/> 
                                <TextBlock Text="Address: " Margin="48,0,0,0" FontWeight="Bold" Grid.Row="4" Grid.Column="1" /> 
                                <TextBlock Text="City: " Margin="48,0,0,0" FontWeight="Bold" Grid.Row="5" Grid.Column="1" /> 
                                <TextBlock Text="65" Margin="48,0,0,0" Grid.Row="5" Grid.Column="2" /> 
                                <TextBlock Text="Phone: " Margin="48,0,0,0" FontWeight="Bold" Grid.Row="6" Grid.Column="1" /> 
                                <TextBlock Text="76786576" Margin="48,0,0,0" Grid.Row="6" Grid.Column="2" /> 
                            </Grid> 
                        </Border> 
                    </telerikNavigation:RadTabItem> 
                    <telerikNavigation:RadTabItem Margin="10,0,0,0" Height="24" FontWeight="Bold" FontSize="11" Foreground="Black"
                        <telerikNavigation:RadTabItem.Header> 
                            <StackPanel Orientation="Horizontal"
                                <Image Source="/linnworks.cloud.component.stockcontrol;Component/Images/plus.png" Width="16" /> 
                                <TextBlock Text=" Images" /> 
                            </StackPanel> 
                        </telerikNavigation:RadTabItem.Header> 
                    </telerikNavigation:RadTabItem> 
                </telerikNavigation:RadTabControl> 
            </Grid> 
        </DataTemplate>     
    </UserControl.Resources> 
 
    <Grid x:Name="LayoutRoot" Loaded="LayoutRoot_Loaded"
        <Grid> 
            <Grid.RowDefinitions> 
                <RowDefinition Height="0*"/> 
                <RowDefinition Height="66"/> 
                <RowDefinition/> 
            </Grid.RowDefinitions> 
            <telerikGridView:RadGridView x:Name="inventory_grid" Grid.Row="2" AutoGenerateColumns="False" CanUserInsertRows="False" EditTriggers="None" ScrollMode="RealTime" HierarchyChildTemplate="{StaticResource GridHierarchy}"
                <telerikGridView:RadGridView.Columns> 
                    <telerikGridView:GridViewDataColumn Header="Item #" UniqueName="Number" DataMemberBinding = "{Binding ItemNumber}" Width="8*" IsReadOnly="True" EditTriggers="None"/> 
                    <telerikGridView:GridViewDataColumn Header="Title" UniqueName="Title"  DataMemberBinding = "{Binding ItemTitle}" Width="22*" IsReadOnly="True"/> 
                    <telerikGridView:GridViewDataColumn Header="Category" UniqueName="Category" DataMemberBinding = "{Binding CategoryName}" Width="33*" IsReadOnly="True"/> 
                    <telerikGridView:GridViewDataColumn Header="Quantity" UniqueName="Quantity" DataMemberBinding = "{Binding Quantity, Mode=TwoWay}" IsReadOnly="True" Width="8*"/> 
                    <telerikGridView:GridViewDataColumn Header="Value" UniqueName="Value" Width="8*" DataMemberBinding="{Binding ItemsValue, Mode=TwoWay}" IsReadOnly="True" DataFormatString="{}{0:C2}"/> 
                    <telerikGridView:GridViewDataColumn Header="Unit Cost" UniqueName="UnitCost" DataMemberBinding = "{Binding RetailPrice, Mode=TwoWay}" IsReadOnly="True" DataFormatString="{}{0:C2}" Width="8*"/> 
                    <telerikGridView:GridViewDataColumn Header="ItemID" UniqueName="Id" DataMemberBinding = "{Binding pkStockItemID}" Width="0" IsReadOnly="True" EditTriggers="None" IsVisible="False"/> 
                </telerikGridView:RadGridView.Columns> 
 
            </telerikGridView:RadGridView> 
        </Grid> 
    </Grid> 
</UserControl> 

I need to get <telerikInput:RadComboBox x:Name="inventory_hierCategory"> in my code to add some items.
Thank you.

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 Oct 2009, 03:36 PM
Hello,

You can use Loaded event of this control - sender argument is the current combo instance.

Regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Hazeest
Top achievements
Rank 1
answered on 28 Oct 2009, 05:06 PM
Thank you for quick response. 
But I have another problem.
In this hierarchy I will have a "Save" button which should have an access to all textboxes and comboboxes to update the database. How can I get all this elements?
0
Accepted
Vlad
Telerik team
answered on 29 Oct 2009, 06:14 AM
Hi,

Better will be if you use MVVM pattern to bind (TwoWay) you controls on the page and later you can access desired item(s) in your model to save the result in the data-base.

Best wishes,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Hazeest
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Hazeest
Top achievements
Rank 1
Share this question
or