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

Hide expand button on childGrid

10 Answers 102 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Orit
Top achievements
Rank 1
Orit asked on 09 Sep 2009, 06:57 AM
Hello
I have hierarchy with 3 levels
father-child-subChild.
according to my data-
the father rows will always have children
but not all the child rows will have subChildRows
so I need to be able to hide the expand button in the childGrid
I saw your example of:

this

 

.MasterTableDefinition_PreviewDataRowCreate
but how or where can I add this method to my childGrid
Thanks!
Orit

 

10 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 09 Sep 2009, 09:07 AM
Hi Orit,

You will need to manually define the HierarchyChildTemplate of the father grid, place the child grid inside it and attach to its PreviewDataRecordCreate event. I hope this helps.

Sincerely yours,
Ross
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
Orit
Top achievements
Rank 1
answered on 09 Sep 2009, 09:58 AM
There is no 

PreviewDataRecordCreate  property in my HierarchyChildTemplate

 

<telerik:RadGridView Name="gvAccount" Margin="2,2,2,2"   
                                         CanUserReorderColumns="False" ColumnsWidthMode="Fill" HorizontalContentAlignment="Right" 
                                         CanUserFreezeColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" CanUserSortColumns="False" 
                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="True" CanUserInsertRows="False">  
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="BudgetTypeName" Header="תקציב"  Width="60"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון/&#13;סעיף/תת סעיף"  Width="160" CellStyle="{StaticResource ToolTipColumnStyle}"/>                                  
                            <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Number" Header="מס' חשבון/&#13;סעיף/תת סעיף" Width="110" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="TotalBudget" Header="הקצבה&#13;כוללת&#13;(אש''ח)"  Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;(אש''ח)" Width="75" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילויות&#13;(אש''ח)" Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumOrderAllocation" Header="התחייבות&#13;לפעילויות&#13;(אש''ח)" Width="75" /> 
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל&#13;(אש''ח)"  Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום&#13;(אש''ח)" Width="75"/>  
                            <telerik:GridViewDataColumn IsReadOnly="True" DataFormatString="{}{0:#,##0.00₪}" UniqueName="ActivityTypeName" Header="סוג&#13;פעילות" Width="130"/>  
                        </telerik:RadGridView.Columns> 
                        <telerik:RadGridView.HierarchyChildTemplate> 
                            <DataTemplate>                             
                                    <telerik:RadGridView Name="gvBudget" Loaded="OnChildGridLoaded" 
                                                         CanUserReorderColumns="False" ColumnsWidthMode="Fill" HorizontalContentAlignment="Right" 
                                                         CanUserFreezeColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" 
                                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="False" ClipToBounds="True" CellEditEnded="gvBudget_CellEditEnded">  
                                        <telerik:RadGridView.Columns> 
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="aa" Header="סוג תקציב"  Width="33"/>  
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון"  Width="160"  CellStyle="{StaticResource ToolTipColumnStyle}"/>  
                                                <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Number" Header="מספר חשבון"  Width="110"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="TotalBudget" Header="הקצבה כוללת &#13;אש''ח"  Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;אש''ח" Width="75" /> 
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילות&#13;אש''ח" Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderAllocation" Header="התחיבות&#13;לפעילות&#13;אש''ח" Width="75" /> 
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל"  Width="75"/>  
                                                <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום" Width="75"/>  
                                                <telerik:GridViewComboBoxColumn UniqueName="ActivityTypeID" DataMemberBinding="{Binding ActivityTypeID}" DisplayMemberPath="Name" SelectedValueMemberPath="Id" Header="סוג&#13;פעילות" Width="130"  /> 
                                        </telerik:RadGridView.Columns> 
                                        <telerik:RadGridView.HierarchyChildTemplate> 
                                            <DataTemplate> 
                                                    <telerik:RadGridView Name="gvSubBudget" Loaded="OnSubChildGridLoaded" CellEditEnded="gvBudget_CellEditEnded" 
                                                         CanUserReorderColumns="False" ColumnsWidthMode="Fill" HorizontalContentAlignment="Right" 
                                                         CanUserFreezeColumns="False" ShowGroupPanel="False" AutoGenerateColumns="False" 
                                                         FlowDirection="RightToLeft" IsFilteringAllowed="False" ShowColumnHeaders="False" ClipToBounds="True">  
                                                    <telerik:RadGridView.Columns> 
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="aa" Header="סוג תקציב"  Width="32"/>  
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Name" Header="שם חשבון"  Width="160"  CellStyle="{StaticResource ToolTipColumnStyle}"/>  
                                                        <telerik:GridViewDataColumn IsReadOnly="True" UniqueName="Number" Header="מספר חשבון"  Width="110"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="TotalBudget" Header="הקצבה כוללת &#13;אש''ח"  Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceBudgetAllocation" Header="יתרה&#13;לתקצוב&#13;אש''ח" Width="75" /> 
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumBudgetRequest" Header="שריון &#13;לפעילות&#13;אש''ח" Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderAllocation" Header="התחיבות&#13;לפעילות&#13;אש''ח" Width="75" /> 
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="SumOrderPaid" Header="שולם&#13;בפועל"  Width="75"/>  
                                                        <telerik:GridViewDataColumn DataFormatString="{}{0:#,##0.00₪}" IsReadOnly="True" UniqueName="BalanceToPay" Header="יתרה&#13;לתשלום" Width="75"/>  
                                                        <telerik:GridViewComboBoxColumn UniqueName="ActivityTypeID" DataMemberBinding="{Binding ActivityTypeID}" DisplayMemberPath="Name" SelectedValueMemberPath="Id" Header="סוג&#13;פעילות" Width="130"/>  
                                                </telerik:RadGridView.Columns> 
                                                    </telerik:RadGridView>                                                  
                                            </DataTemplate> 
                                        </telerik:RadGridView.HierarchyChildTemplate> 
                                    </telerik:RadGridView>                               
                            </DataTemplate> 
                        </telerik:RadGridView.HierarchyChildTemplate>                       
                    </telerik:RadGridView> 
Thanks

0
Rossen Hristov
Telerik team
answered on 09 Sep 2009, 10:33 AM
Hi Orit,

Please, excuse me I made a mistake. You should attach to the child table definition's event. Something like this (If you have 3-level hierarchy with Clubs -> Players -> Games):

        public MainPage() 
        { 
            InitializeComponent(); 
             
            GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition(); 
            playersTableDefinition.Relation = new PropertyRelation("Players"); 
            this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition); 
 
            GridViewTableDefinition gamesTableDefinition = new GridViewTableDefinition(); 
            gamesTableDefinition.Relation = new PropertyRelation("Games"); 
            playersTableDefinition.ChildTableDefinitions.Add(gamesTableDefinition); 
            playersTableDefinition.PreviewDataRecordCreate += new System.EventHandler<DataRecordCreateEventArgs>(playersTableDefinition_PreviewDataRecordCreate); 
 
            this.clubsGrid.ItemsSource = Club.GetClubs(); 
        } 
 
        void playersTableDefinition_PreviewDataRecordCreate(object sender, DataRecordCreateEventArgs e) 
        { 
             
        } 
 

I hope this helps.

All the best,
Ross
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
Orit
Top achievements
Rank 1
answered on 09 Sep 2009, 11:27 AM
Hi
I try to use your code
but the "playersTableDefinition_PreviewDataRecordCreate" dose not happen
Thanks
0
Orit
Top achievements
Rank 1
answered on 10 Sep 2009, 07:39 AM
Can you please answer me?
I use your code but when I click on the expand button
nothing happens

Thanks
Orit
0
Rossen Hristov
Telerik team
answered on 10 Sep 2009, 08:49 AM
Hello Orit,

I have prepared a small sample project and attached it. Please not that you should get the binaries from our Latest Internal Build and everything should work as expected.

Here is part of the code:

using System.Windows.Controls; 
using Telerik.Windows.Controls; 
using Telerik.Windows.Data; 
 
namespace TicketID_234244_NestedHierarchyChildTemplates 
    public partial class MainPage : UserControl 
    { 
        public MainPage() 
        { 
            InitializeComponent(); 
             
            GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition(); 
 
            playersTableDefinition.PreviewDataRecordCreate += OnPlayersTableDefinitionPreviewDataRecordCreate; 
 
            playersTableDefinition.Relation = new PropertyRelation("Players"); 
            this.clubsGrid.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition); 
 
            GridViewTableDefinition gamesTableDefinition = new GridViewTableDefinition(); 
            gamesTableDefinition.Relation = new PropertyRelation("Games"); 
            playersTableDefinition.ChildTableDefinitions.Add(gamesTableDefinition); 
 
            this.clubsGrid.ItemsSource = Club.GetClubs(); 
        } 
 
        static void OnPlayersTableDefinitionPreviewDataRecordCreate(object sender, DataRecordCreateEventArgs e) 
        { 
            Player player = (Player)e.Data; 
            e.IsExpandableRecord = player.Games.Count > 0; 
        } 
    } 

<UserControl x:Class="TicketID_234244_NestedHierarchyChildTemplates.MainPage" 
    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"  
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"  
    mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480"
    <Grid> 
        <telerik:RadGridView Name="clubsGrid"  
                             AutoGenerateColumns="False" 
                             ColumnsWidthMode="Auto"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn  
                    Header="Name"  
                    DataMemberBinding="{Binding Name}"/> 
                <telerik:GridViewDataColumn  
                    Header="Est."  
                    DataMemberBinding="{Binding Established}" 
                    DataFormatString="{}{0:yyyy}"/> 
                <telerik:GridViewDataColumn  
                    Header="Stadium" 
                    DataMemberBinding="{Binding StadiumCapacity}"  
                    DataFormatString="{}{0:N0}"/> 
            </telerik:RadGridView.Columns> 
            <telerik:RadGridView.HierarchyChildTemplate> 
                <DataTemplate> 
                    <telerik:RadGridView 
                        Name="playersGrid"  
                        ShowGroupPanel="False" 
                        AutoGenerateColumns="False" 
                        ColumnsWidthMode="Auto"
                        <telerik:RadGridView.Columns> 
                            <telerik:GridViewDataColumn  
                                Header="Name"  
                                DataMemberBinding="{Binding Name}"/> 
                            <telerik:GridViewDataColumn  
                                Header="Number"  
                                DataMemberBinding="{Binding Number}"/> 
                            <telerik:GridViewDataColumn  
                                Header="Position"  
                                DataMemberBinding="{Binding Position}"/> 
                            <telerik:GridViewDataColumn  
                                Header="Country"  
                                DataMemberBinding="{Binding Country}"/> 
                        </telerik:RadGridView.Columns> 
                        <telerik:RadGridView.HierarchyChildTemplate> 
                            <DataTemplate> 
                                <telerik:RadGridView  
                                    Name="gamesGrid"  
                                    ShowGroupPanel="False" 
                                    ColumnsWidthMode="Auto"
                                </telerik:RadGridView> 
                            </DataTemplate> 
                        </telerik:RadGridView.HierarchyChildTemplate> 
                    </telerik:RadGridView> 
                </DataTemplate> 
            </telerik:RadGridView.HierarchyChildTemplate> 
        </telerik:RadGridView> 
    </Grid> 
</UserControl> 
 

Please, let us know if the problem still exists after you upgrade to the Latest Internal Build binaries.

Kind regards,
Ross
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
Orit
Top achievements
Rank 1
answered on 10 Sep 2009, 09:26 AM

I set the ItemsSource of my father grid
to be a dataSet with 3 dataTables
Account-Budget-SubBudget
and with Relations:

 

 dsAccount.Relations.Add("BudgetRelation",  
                    dsAccount.Tables["Account"].Columns["Number"],  
                    dsAccount.Tables["Budget"].Columns["ParentID"]);  
                      
                    dsAccount.Relations.Add("SubBudgetRelation",  
                    dsAccount.Tables["Budget"].Columns["Number"],  
                    dsAccount.Tables["SubBudget"].Columns["ParentID"]);  
                      
                    return dsAccount; 

and I did not use the way you suggest
 GridViewTableDefinition playersTableDefinition = new GridViewTableDefinition();  
 
                playersTableDefinition.PreviewDataRecordCreate += OnPlayersTableDefinitionPreviewDataRecordCreate;  
 
                playersTableDefinition.Relation = new PropertyRelation("Budget");  
                this.gvAccount.TableDefinition.ChildTableDefinitions.Add(playersTableDefinition);  
 
                GridViewTableDefinition gamesTableDefinition = new GridViewTableDefinition();  
                gamesTableDefinition.Relation = new PropertyRelation("SubBudget");  
                playersTableDefinition.ChildTableDefinitions.Add(gamesTableDefinition); 
now
when I try to use it
when I click the expand button-
1. the OnPlayersTableDefinitionPreviewDataRecordCreate does not raise!
2. I see a black row- like an empty grid
and a normal grid with the expected data
if I remove the relation from my dataSet
I see only empty grid
any idea??
Thanks!
0
Rossen Hristov
Telerik team
answered on 10 Sep 2009, 09:31 AM
Hi Orit,

Can you please send us your project. Thanks.

All the best,
Ross
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
Orit
Top achievements
Rank 1
answered on 10 Sep 2009, 10:12 AM
How can I attach files?
0
Vlad
Telerik team
answered on 10 Sep 2009, 10:32 AM
Hi Orit,

You can open support ticket.

Sincerely yours,
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
Orit
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Orit
Top achievements
Rank 1
Vlad
Telerik team
Share this question
or