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

Child Grid Not Displaying Columns When ShowColumnFooters set to true

2 Answers 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Boots
Top achievements
Rank 1
Boots asked on 27 Apr 2010, 05:26 PM
Hello,

Just updated my controls to 2010.1.402.1. We were going off of the GridView/Hierarchy/CustomHierarchy example. in the DataLoading method if we set ShowColumnFooters = true then none of the columns are displayed. We did try it with a DataTemplate in xaml instead and that seemed to work just fine. Any ideas on how to display the column footers without setting it all up in xaml?

<Window  
    x:Class="RadGridViewTest.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    xmlns:local="clr-namespace:RadGridViewTest" 
    Title="Window1"
    <Grid> 
        <telerik:RadGridView  
            x:Name="rgv"  
            AutoGenerateColumns="False" DataLoading="RadGridView_DataLoading"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn UniqueName="Column1" Header="Column 1" /> 
                <telerik:GridViewDataColumn UniqueName="Column2" Header="Column 2" /> 
            </telerik:RadGridView.Columns> 
        </telerik:RadGridView> 
    </Grid> 
</Window> 

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
using System.Collections; 
using System.Collections.ObjectModel; 
using Telerik.Windows.Controls.GridView; 
using Telerik.Windows.Data; 
using Telerik.Windows.Controls; 
 
namespace RadGridViewTest 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    { 
        public Window1() 
        { 
            InitializeComponent(); 
 
            ObservableCollection<Column> Columns = new ObservableCollection<Column>(); 
            ObservableCollection<ChildGridColumn> ChildGridColumns = new ObservableCollection<ChildGridColumn>(); 
 
            for (int i = 0; i < 100; i++) 
                ChildGridColumns.Add(new ChildGridColumn(i)); 
 
            for (int i = 0; i < 100; i++) 
                Columns.Add(new Column(i, i, ChildGridColumns)); 
 
            this.rgv.ItemsSource = Columns; 
 
 
            GridViewTableDefinition gvtd = new GridViewTableDefinition(); 
            gvtd.Relation = new PropertyRelation("ChildGridColumns"); 
            this.rgv.ChildTableDefinitions.Add(gvtd); 
        } 
 
        private void RadGridView_DataLoading(object sender, Telerik.Windows.Controls.GridView.GridViewDataLoadingEventArgs e) 
        { 
            GridViewDataControl dataControl = (GridViewDataControl)sender; 
            if (dataControl.ParentRow != null
            { 
                dataControl.ShowColumnFooters = true
 
                dataControl.AutoGenerateColumns = false
                dataControl.Columns.Add(new Telerik.Windows.Controls.GridViewDataColumn() 
                { 
                    UniqueName = "ChildColumn1"
                    Header = "Column 1" 
                }); 
 
                dataControl.Columns.Add(new Telerik.Windows.Controls.GridViewDataColumn() 
                { 
                    UniqueName = "ChildColumn2"
                    Header = "Column 2" 
                }); 
 
                dataControl.Columns.Add(new Telerik.Windows.Controls.GridViewDataColumn() 
                { 
                    UniqueName = "ChildColumn3"
                    Header = "Column 3" 
                }); 
            } 
        } 
    } 
 
    public class Column 
    { 
        public Column(int Column1, int Column2, ObservableCollection<ChildGridColumn> ChildGridColumns) 
        { 
            this.Column1 = Column1; 
            this.Column2 = Column2; 
            this.ChildGridColumns = ChildGridColumns; 
        } 
 
        public int Column1 { getset; } 
        public int Column2 { getset; } 
 
        public ObservableCollection<ChildGridColumn> ChildGridColumns { getset; } 
        
    } 
 
    public class ChildGridColumn 
    { 
        public ChildGridColumn(int Num) 
        { 
            this.ChildColumn1 = Num; 
            this.ChildColumn2 = Num; 
            this.ChildColumn3 = Num; 
        } 
        public int ChildColumn1 { getset; } 
        public int ChildColumn2 { getset; } 
        public int ChildColumn3 { getset; } 
    } 
 

Thanks Much,
~Boots

2 Answers, 1 is accepted

Sort by
0
Accepted
Maya
Telerik team
answered on 30 Apr 2010, 02:47 PM
Hello Boots,

The fact that the data in the columns in Child Hierarchy does not show when ShowColumnFooters is set to "true" is a known issue and we are working on its fix.
For the time being I may suggest you as a possible workaround to set "Width" Property of the ChildGrid in "DataLoading" event. Furthermore, you may set its horizontal alignment so that it is in the appropriate position. Thus the code snippet you need to implement in the "DataLoading"  event is:

dataControl.Width = dataControl.ParentRow.ActualWidth - 80;
dataControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; 
dataControl.ShowColumnFooters = true;

The number "80" added is to avoid the appearance of a scroll bar.

I hope this helps.

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
Boots
Top achievements
Rank 1
answered on 30 Apr 2010, 03:17 PM
Hi Maya ,

Thank you for getting back to me so quickly and giving me a workaround that can be implemented right away.

Thanks Again,
~Boots
Tags
GridView
Asked by
Boots
Top achievements
Rank 1
Answers by
Maya
Telerik team
Boots
Top achievements
Rank 1
Share this question
or