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

[Solved] Child Hierarchy table is blank when parent gridview's AutoGenerateColumns = false

3 Answers 241 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.
Lance
Top achievements
Rank 1
Lance asked on 03 Nov 2010, 07:27 AM
Hi,

I have a RadGridView that is bound to an ObservableCollection of objects that have a property that is an ObservableCollection.  To represent this, my gridview has a child gridview that is bound to this property.  When I have the parent gridview's AutoGenerateColumns property set to false, the child grid is blank when expanded.  It takes up the appropriate space as it would if visible but is just a blank white rectangle (see attachment - GridViewWithBlankChild.gif).  If I set the parent gridview's AutoGenerateColumns property to true it all works as I would expect (see attachment - GridViewAutoGenerateColumnsIsTrue.gif).  I need to define both the parent and child gridview columns so this is not an option.  Please help.

Below is my xaml: 
<telerik:RadGridView x:Name="grdClientExecForecasts" 
     TabNavigation="Cycle" 
     DataLoadMode="Asynchronous"
     AutoGenerateColumns="True"
     CanUserReorderColumns="False"
     CanUserResizeColumns="False"
     IsEnabled="True" 
     IsReadOnly="False"
     MaxWidth="1825" 
     MaxHeight="840" 
     MinHeight="0"      
     VerticalAlignment="Stretch"
     HorizontalAlignment="Left"
     SelectionMode="Single"
     RowDetailsVisibilityMode="Collapsed"
     EditTriggers="CellClick"
     SelectionUnit="Cell"
     IsFilteringAllowed="False"
     ShowGroupPanel="False"
     ShowColumnFooters="False"
     ShowGroupFooters="False"
     ShowInsertRow="False"
     RowIndicatorVisibility="Collapsed" 
     ClipboardCopyMode="All"
     ClipboardPasteMode="None"
     KeyDown="grdClientExecForecasts_KeyDown"
     BeginningEdit="grdClientExecForecasts_BeginningEdit"
     CurrentCellChanged="grdClientExecForecasts_CurrentCellChanged"
        >
     <telerik:RadGridView.Columns>
         <this:ImageColumn Source="../images/edit.png" MouseLeftButtonDown="Edit_MouseLeftButtonDown"  Tooltip="Click to edit client executive forecast." ImageHeight="15" ImageWidth="15" />
         <telerik:GridViewDataColumn 
             Header="Id" Width="50"
             DataMemberBinding="{Binding ClientExecForecastsId}"                            
             IsReadOnly="True"/>
         <telerik:GridViewDataColumn
             Header="Client Name" Width="200"
             DataMemberBinding="{Binding ClientName}" 
             IsReadOnly="True"/>
         <telerik:GridViewDataColumn
             Header="Product" Width="200"
             DataMemberBinding="{Binding ProductName}" 
             IsReadOnly="True"/>
         <telerik:GridViewDataColumn 
             Header="Client Type" Width="100" MaxWidth="100" MinWidth="75" 
             DataMemberBinding="{Binding ClientTypeId, Mode=TwoWay, Converter={StaticResource clientTypeConverter}}"
             IsReadOnly="True"/>
         <telerik:GridViewDataColumn 
             Header="Agency" Width="200" MaxWidth="200" MinWidth="76" 
             DataMemberBinding="{Binding AgencyName}" 
             IsReadOnly="True"/>
         <this:ImageColumn Source="../images/delete.png" MouseLeftButtonDown="Delete_MouseLeftButtonDown" Tooltip="Click to delete client executive forecast." ImageHeight="15" ImageWidth="15" />
     </telerik:RadGridView.Columns>
     <telerik:RadGridView.HierarchyChildTemplate>
         <DataTemplate>
             <telerik:RadGridView AutoGenerateColumns="False" ItemsSource="{Binding ClientExecForecastAmounts}" DataLoadMode="Asynchronous" >
                 <telerik:RadGridView.Columns>
                     <telerik:GridViewDataColumn Header="Station" DataMemberBinding="{Binding StationId}" />
                 </telerik:RadGridView.Columns>
             </telerik:RadGridView>                                                 
         </DataTemplate>
     </telerik:RadGridView.HierarchyChildTemplate>
     <telerik:RadGridView.ChildTableDefinitions>
         <telerik:GridViewTableDefinition>
             <telerik:GridViewTableDefinition.Relation>
                 <telerik:PropertyRelation ParentPropertyName="ClientExecForecastAmounts"/>
             </telerik:GridViewTableDefinition.Relation>
         </telerik:GridViewTableDefinition>
     </telerik:RadGridView.ChildTableDefinitions>
 </telerik:RadGridView>

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 03 Nov 2010, 08:27 AM
Hello Tim English,

I tried to reproduce the issue you specified, but I was not able to. I am sending you the sample project I tested the problem on. You may take a look at it and share if there are some discrepancies between it and your requirements.

Greetings,
Maya
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
Lance
Top achievements
Rank 1
answered on 04 Nov 2010, 01:26 AM
Hi Maya,

Thanks for your reply.  I've discovered that the problem occurs when you wrap the RadGridView in a ViewBox.  If you wrap the RadGridView in your example in a ViewBox you will be able to reproduce this issue.

0
Maya
Telerik team
answered on 05 Nov 2010, 09:39 AM
Hello Tim English,

Indeed, you are quite right - once the grid is defined inside a ViewBox, the described behavior occurs. We would investigate the issue and inform you as soon as we have a solution on the topic.
For the time being I may propose you to set the child table inside RowDetails instead of HirarchyChildTemplate:

<Viewbox>
            <telerik:RadGridView Grid.Row="0"
                                 Name="clubsGrid" ItemsSource="{Binding Clubs}"
                                 AutoGenerateColumns="False"           
                                 Margin="5">
                <telerik:RadGridView.RowDetailsTemplate>
                    <DataTemplate>
                        <telerik:RadGridView Name="playersGrid"
                                             ItemsSource="{Binding Players}"
                                             AutoGenerateColumns="False">
                            <telerik:RadGridView.Columns>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Number}"/>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
                                <telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
                            </telerik:RadGridView.Columns>
                        </telerik:RadGridView>
                    </DataTemplate>
                </telerik:RadGridView.RowDetailsTemplate>              
             
                <telerik:RadGridView.Columns>          
                    <telerik:GridViewToggleRowDetailsColumn />
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding Established}"
                                                Header="Est."
                                                DataFormatString="{}{0:yyyy}"/>
                    <telerik:GridViewDataColumn DataMemberBinding="{Binding StadiumCapacity}"
                                                Header="Stadium"
                                                DataFormatString="{}{0:N0}"/>
                </telerik:RadGridView.Columns>             
            </telerik:RadGridView>
        </Viewbox>

Furthermore, when defining the RadGridView inside a control that is measured with Infinity - the ViewBox in this case, the virtualization of the grid will be turned off. So, if you are working with a large data set, the performance will be decreased.
 

Sincerely yours,
Maya
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
Tags
GridView
Asked by
Lance
Top achievements
Rank 1
Answers by
Maya
Telerik team
Lance
Top achievements
Rank 1
Share this question
or