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

hierarchy Issue

6 Answers 90 Views
GridView
This is a migrated thread and some comments may be shown as answers.
FantasmaWeb
Top achievements
Rank 1
FantasmaWeb asked on 09 Sep 2010, 06:35 PM
hello:

    I have a trouble with the Hierarchy in the gridview.  I have my gridview,that filled it on codebehind and everything it´s working fine even the hierarchy .. But when I try to use a HierarchyChildTemplate  I just see the plus Symbol, what that means I got a childrows but when i click on the Symbol nothing happens.
  

 

 

 

<telerik:RadGridView.HierarchyChildTemplate><DataTemplate><telerik:RadGridView x:Name="RadGridViewChildrenMiles" ColumnsWidthMode="Auto"

 

 

 

AutoGenerateColumns="False">
<telerik:RadGridView.Columns><grid:GridViewDataColumnHeader="Descripcion"

 

 

 

DataMemberBinding="{Binding Descripcion}"/></telerik:RadGridView.Columns>

 

 

 

 

</telerik:RadGridView>
</DataTemplate></telerik:RadGridView.HierarchyChildTemplate>


Sorry if my english it´s no so good

Regards
 
 Cesar

 

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Sep 2010, 07:17 AM
Hi,

 You child grid is not bound - you need to assign ItemsSource.

Kind regards,
Vlad
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
FantasmaWeb
Top achievements
Rank 1
answered on 10 Sep 2010, 03:44 PM

I assign  the itemsource in the codebehind and the table definition  just like one of your examples, in fact  the child grid is bound before set the HierarchyChildTemplate but when i put the HIerarchyChildTemplate just i can't see the child grid

 

Telerik.Windows.Controls.GridViewTableDefinition detailsTableDefinition = new Telerik.Windows.Controls.GridViewTableDefinition();
  
detailsTableDefinition.Relation = new Telerik.Windows.Data.PropertyRelation("Details");
  
this.myRadGridViewMiles.TableDefinition.ChildTableDefinitions.Add(detailsTableDefinition);

 

Regards 

  Cesar

 

0
Vlad
Telerik team
answered on 10 Sep 2010, 03:56 PM
Hi 

 Since you have defined template this automatic binding will not work. To achieve your goal you can set ItemsSource="{Binding Details}" in XAML for the child grid directly and insert an empty table definition with no relations just to tell the grid that you have hierarchy. You can check our demo for more info.

Greetings,
Vlad
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
FantasmaWeb
Top achievements
Rank 1
answered on 10 Sep 2010, 07:31 PM
Im still have the same problem.... this is my Grid definition

<telerik:RadGridView Margin="0,0,0,1"                           
                           x:Name="myRadGridViewMiles"                                                     
                           ShowColumnFooters="True"                                                        
                           MaxWidth="910"                                                       
                           AutoGenerateColumns="False" 
                           Height="470"
                           IsReadOnly="True"                           
                           ShowGroupPanel="False"                             
                           FrozenColumnCount="2"                      
                           CanUserFreezeColumns="False">
           <telerik:RadGridView.ChildTableDefinitions>
              <telerik:GridViewTableDefinition />
          </telerik:RadGridView.ChildTableDefinitions>
          <telerik:RadGridView.Columns>
              <telerik:GridViewDataColumn Width="180" 
                                          Header="Programa"
                                          IsFilterable="False"  
                                          FooterTextAlignment="Right"
                                       DataMemberBinding="{Binding Programa}">
                  <telerik:GridViewDataColumn.AggregateFunctions>
                      <dataTelerik:SumFunction Caption="Total:" SourceField="Totals" />
                      <dataTelerik:SumFunction Caption="Canal:"  SourceField="Totals" />
                      <dataTelerik:SumFunction Caption="% Logro:"  SourceField="Totals" />
                  </telerik:GridViewDataColumn.AggregateFunctions>
                  <telerik:GridViewDataColumn.Footer>
                      <StackPanel  Orientation="Vertical" Margin="0,0,0,0">
                          <gridView:AggregateResultsList ItemsSource="{Binding}">
                              <gridView:AggregateResultsList.ItemTemplate>
                                  <DataTemplate>
                                      <Grid HorizontalAlignment="Right"
                                                 VerticalAlignment="Center">
                                          <Grid.ColumnDefinitions>
                                              <ColumnDefinition Width="34" />
                                              <ColumnDefinition Width="55"/>
                                          </Grid.ColumnDefinitions>
                                          <TextBlock VerticalAlignment="Center"  
                                                             Grid.Column="1"
                                                      FontSize="14" 
                                                     FontFamily="Calibri"
                                                     FontWeight="Bold"
                                                         HorizontalAlignment="Right"  
                                                         Text="{Binding Caption}" />
                                      </Grid>
                                  </DataTemplate>
                              </gridView:AggregateResultsList.ItemTemplate>
                          </gridView:AggregateResultsList>
                      </StackPanel>
                  </telerik:GridViewDataColumn.Footer>
              </telerik:GridViewDataColumn>
 </telerik:RadGridView.Columns>
            
          <telerik:RadGridView.HierarchyChildTemplate>
              <DataTemplate>
                  <telerik:RadGridView x:Name="RadGridView1" 
                                       CanUserFreezeColumns="False" 
                                       AutoGenerateColumns="False"
                                       ItemsSource="{Binding Details}"  
                                       ShowGroupPanel="False" 
                                       IsReadOnly="True"      >
                      <telerik:GridViewDataColumn DataMemberBinding="{Binding Sem52}" Header="Product ID" />
                  </telerik:RadGridView>
              </DataTemplate>
          </telerik:RadGridView.HierarchyChildTemplate>
      </telerik:RadGridView>

and this is the model what I Use to bind the Grid
public class Details : INotifyPropertyChanged
      {
          private double sem52 = 0;
          public double Sem52
          {
              get { return sem52; }
              set {
                  if (value != this.sem52)
                  {
                      sem52 = value;
                      this.OnPropertyChanged("Sem52");
                  }
              }
          }
public Details()
          {
             
          }
                                
            
          #region INotifyPropertyChanged Members
          public event PropertyChangedEventHandler PropertyChanged;
          #endregion
          protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
          {
              PropertyChangedEventHandler handler = this.PropertyChanged;
              if (handler != null)
              {
                  handler(this, args);
              }
          }
          private void OnPropertyChanged(string propertyName)
          {
              this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
          }
      }


and the Class that use the Collection for the child items
   public class TabAnual : INotifyPropertyChanged
        {
            public event PropertyChangedEventHandler PropertyChanged;
  
            private ObservableCollection<Details> details;
  
            public TabAnual()
            {
  
            }
  
            protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
            {
                PropertyChangedEventHandler handler = this.PropertyChanged;
                if (handler != null)
                {
                    handler(this, args);
                }
            }
  
            private void OnPropertyChanged(string propertyName)
            {
                this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
            }
             
            
            public ICollection<Details> Details
            {
                get
                {
                    if (null == this.details)
                    {
                        this.details = new ObservableCollection<Details>();
                    }
  
                    return this.details;
                }
            }
  
  
  
            private double totals = 0;
            public double Totals
            {
                get { return totals; }
                set {
                    if (value != this.totals)
                    {
                        totals = value;
                        this.OnPropertyChanged("Totals");
                    }
                }
            }
  
  
            private double totals_totals = 0;
            public double Totals_totals
            {
                get { return totals_totals; }
                set {
                    if (value != this.totals_totals)
                    {
                        totals_totals = value;
                        this.OnPropertyChanged("Totals_totals");
                    }
                }
            }
  
  
  
            private double totals_canales;
            public double Totals_canales
            {
                get { return totals_canales; }
                set {
                    if (value != this.totals_canales)
                    {
                        totals_canales = value;
                        this.OnPropertyChanged("Totals_canales");
                    }
                }
            }
  
            private double totals_logro;
            public double Totals_logro
            {
                get { return totals_logro; }
                set {
                    if (value != this.totals_logro)
                    {
                        totals_logro = value;
                        this.OnPropertyChanged("Totals_logro");
                    }
                }
            }
  
  
            private string _programa;
            public string Programa
            {
                get { return _programa; }
                set {
                    if (value != this._programa)
                    {
                        _programa = value;
                        this.OnPropertyChanged("Programa");
                    }
                }
            }
}

Regards

 Cesar 
0
Accepted
Vlad
Telerik team
answered on 13 Sep 2010, 07:40 AM
Hi FantasmaWeb,

The syntax of the child table is not correct - column declarations should be inside Columns.

Best wishes,
Vlad
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
FantasmaWeb
Top achievements
Rank 1
answered on 13 Sep 2010, 06:42 PM

 

It works like a charm. Thanks for everything .. I didn't see it before

Regards

Cesar
Tags
GridView
Asked by
FantasmaWeb
Top achievements
Rank 1
Answers by
Vlad
Telerik team
FantasmaWeb
Top achievements
Rank 1
Share this question
or