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

how to add data from list to Hierarchical Child template RadGridView ?

2 Answers 39 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Shashank
Top achievements
Rank 1
Shashank asked on 03 Dec 2011, 07:34 AM
Hi,
In my Application I need to use two grids in Hierarchical manner.I am not getting the way to insert data into child grid from list.I am attching image of ma application.and here is my code:

<UserControl x:Class="SilverlightApplication2.MainPage"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"     
    xmlns:telerikGrid="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
    xmlns:telerikQuickStart="clr-namespace:Telerik.Windows.Controls.QuickStart;assembly=Telerik.Windows.Controls"
    xmlns:local="clr-namespace:SilverlightApplication2"
    mc:Ignorable="d"
    d:DesignHeight="589" d:DesignWidth="831">
 
    <Grid x:Name="LayoutRoot" Background="White" Width="880" Height="586">
        <Grid.RowDefinitions>
            <RowDefinition Height="8" />
            <RowDefinition Height="576" />
            <RowDefinition Height="2*" />
        </Grid.RowDefinitions>
         
        <Border telerikQuickStart:ThemeAwareBackgroundBehavior.IsEnabled="True" Grid.RowSpan="2" Margin="-7,-3,0,22" HorizontalAlignment="Left" Width="880">
            <telerikGrid:RadGridView ShowColumnFooters="True" AutoGenerateColumns="False" ItemsSource="{Binding lstVessel}"  CanUserInsertRows="True" Name="radGridView1" Height="420" Width="880" IsReadOnly="False" >     
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding VesselType1;}" Width="400"  Header="Vessel Type">
                        <telerik:GridViewColumn.Footer>
                            <telerik:RadButton x:Name="Add"  Content="AddNewRow" Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=radGridView1}"  />
                        </telerik:GridViewColumn.Footer>
                        </telerik:GridViewDataColumn>
                   <telerik:GridViewDataColumn DataMemberBinding="{Binding IsActive1}" Header="Is Active" Width="400"/>   
                </telerik:RadGridView.Columns>
                <telerik:RadGridView.ChildTableDefinitions>
                    <telerik:GridViewTableDefinition/>
                </telerik:RadGridView.ChildTableDefinitions>
                <telerik:RadGridView.HierarchyChildTemplate>
                    <DataTemplate >
                        <telerik:RadGridView x:Name="radGridView2" AutoGenerateColumns="False"   ShowColumnFooters="True" ItemsSource="{Binding lstOperationProfile}" Height="217" Width="880"  IsReadOnly="False" Loaded="radGridView2_Loaded">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn IsReadOnly="False" Width="170" Header="OperationID" DataMemberBinding="{Binding Operation}">
                                    <telerik:GridViewColumn.Footer>
                                        <telerik:RadButton x:Name="Add"  Content="AddNewRow" Command="telerikGrid:RadGridViewCommands.BeginInsert" CommandTarget="{Binding ElementName=radGridView1}"  />
                                    </telerik:GridViewColumn.Footer>      
                                </telerik:GridViewDataColumn>
                                <telerik:GridViewDataColumn IsReadOnly="False" Width="170" Header="OperationName" DataMemberBinding="{Binding TimeHrs}"   />
                                <telerik:GridViewDataColumn IsReadOnly="False" Width="170" Header="OperationTime" DataMemberBinding="{Binding TimePercen}" />
                                <telerik:GridViewDataColumn IsReadOnly="False" Width="170" Header="LoadOnGensets" DataMemberBinding="{Binding LoadOnGensets}"/>
                                <telerik:GridViewDataColumn IsReadOnly="False" Width="170" Header="Total" DataMemberBinding="{Binding Total}"  />
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.HierarchyChildTemplate
            </telerikGrid:RadGridView>
        </Border
        <telerik:RadButton Content="Button" Grid.Row="1" Height="35" HorizontalAlignment="Left" Margin="333,15,0,0" Name="radButton1" VerticalAlignment="Top" Width="136" Click="radButton1_Click" />
    </Grid>
</UserControl>



2 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 05 Dec 2011, 01:43 PM
Hello Shashank,

It seems that the code is very similar to some of our examples. However I am not able to find a problem with it whatsoever. I am attaching a sample project quite similar to yours. Could you check it out and see if it works for you? 

Best wishes,
Nik
the Telerik team

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

0
Shashank
Top achievements
Rank 1
answered on 06 Dec 2011, 02:42 AM
Thnx Nic, your application is working fine.There is some problem in my code.I am getting null exception while trying to run it.But i'll rectify it.
Thank you,


Regards,
Shashank
Tags
GridView
Asked by
Shashank
Top achievements
Rank 1
Answers by
Nick
Telerik team
Shashank
Top achievements
Rank 1
Share this question
or