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

RadGridview - Hierarchical: What event is fired when expanding a selected row?

4 Answers 282 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Top Gun
Top achievements
Rank 1
Top Gun asked on 04 May 2011, 02:45 PM

I have a hierarchical telerik gridview in Silverlight.  On the left most column, I have the expand button “+ sign.”  When I click on the expand button “+ sign”, the row expands and I can view more details for my selection.   

What event is fired when I click the expand button “+ sign”?  I want to retrieve data from the database when the user chooses to expand a particular row.  I need to do this in the correct event handler and none of the event handlers seem to work.

4 Answers, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 04 May 2011, 03:06 PM
Hello Top Gun,

You can use RowIsExpandedChanging event. Also, you may take a look at this blog post.

Let us know if you need further help.
 
Best wishes,
Yordanka
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
Top Gun
Top achievements
Rank 1
answered on 04 May 2011, 05:35 PM

RowIsExpandedChanging event was not fired when I selected the expand button "+ sign" on the grid. 
My code works.  I just need the event that fires when I click on the expand button "+ sign."
Here is my Xaml.

<Controls:RadGridView x:Name="PeopleGrid"  Margin="0"
                            RowIndicatorVisibility="Collapsed" IsReadOnly="True" 
                            Width="748" MinHeight="386" MaxHeight="500"
                            AutoGenerateColumns="False"
                            VerticalAlignment="Top" 
                            VerticalContentAlignment="Stretch" 
                            HorizontalContentAlignment="Stretch"  
                            HorizontalAlignment="Stretch"
                            RowIsExpandedChanging="PeopleGrid_RowIsExpandedChanging"
                            >
           <Controls:RadGridView.Columns>
               <Controls:GridViewToggleRowDetailsColumn />
               <Controls:GridViewDataColumn Header="ID" DataMemberBinding="{Binding ID}" />
               <Controls:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" />
               <Controls:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" />
           </Controls:RadGridView.Columns>
           <telerik:RadGridView.RowDetailsTemplate>
               <DataTemplate>
                   <ItemsControl Name="ICClasses" ItemsSource="{Binding Path=ClassList, Mode=OneWay}">
                       <ItemsControl.ItemTemplate>
                           <DataTemplate>
                               <Border BorderBrush="DarkGray" BorderThickness="1" Margin="25,2,0,2" CornerRadius="5">
                                   <Grid HorizontalAlignment="Stretch" ShowGridLines="False" Background="Transparent" Margin="0,1,0,1">
                                       <Grid.ColumnDefinitions>
                                           <ColumnDefinition Width=".4*"/>
                                           <ColumnDefinition Width=".16*"/>
                                           <ColumnDefinition Width=".44*"/>
                                       </Grid.ColumnDefinitions>
                                       <Grid.RowDefinitions>
                                           <RowDefinition Height="*"/>
                                           <RowDefinition Height="*"/>
                                       </Grid.RowDefinitions>
                                       <TextBlock Grid.RowSpan="2" Text="{Binding Subject, Mode=OneWay}" Margin="0,0,40,0" VerticalAlignment="Center" HorizontalAlignment="Right"/>
                                       <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Professor, Mode=OneWay}" HorizontalAlignment="Center" Margin="0,1,0,0"/>
                                       <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Time, Mode=OneWay}" HorizontalAlignment="Center" Margin="0,1,0,0"/>
                                   </Grid>
                               </Border>
                           </DataTemplate>
                       </ItemsControl.ItemTemplate>
                   </ItemsControl>
               </DataTemplate>
           </telerik:RadGridView.RowDetailsTemplate>
       </Controls:RadGridView>


Here is my code behind C#.net (Portion of It)

public MainPage()
        {
            InitializeComponent();
            DataContext = this;
            People = new ObservableCollection<Person>(GetPeople());
            EnterClasses();
            PeopleGrid.ItemsSource = People;
        }
  
public ObservableCollection<Person> People {get; set;}
  
 private List<Person> GetPeople()
        {
            var returnPeople = new List<Person>
                                   {
                                       new Person() {ID = "1234", FirstName = "John", LastName = "Berry"},
                                       new Person() {ID = "3512", FirstName = "Mary", LastName = "Edwards"},
                                       new Person() {ID = "1254", FirstName = "Henry", LastName = "Mas"},
                                       new Person() {ID = "0932", FirstName = "Terry", LastName = "Williams"},
                                       new Person() {ID = "3512", FirstName = "Beth", LastName = "Johnson"},
                                       new Person() {ID = "1254", FirstName = "Summer", LastName = "Sanford"}
                                   };
  
            return returnPeople;
        }
  
   private void EnterClasses()
        {
            var c1 = new ClassSubject()
                        {Professor = "Dr. John Dyer", Subject = "Biology", Time = "3PM - 4:30PM", UniqueId = "53913"};
            var c2 = new ClassSubject() { Professor = "Dr. George Berry", Subject = "Math", Time = "1PM - 2:00PM", UniqueId = "52973" };
  
  
            var classSchedule = new List<ClassSubject>
                                    {
                                        new ClassSubject() {Professor = "Dr. John Dyer", Subject = "Biology", Time = "3PM - 4:30PM", UniqueId = "53913"},
                                        new ClassSubject() {Professor = "Dr. Ron Maher", Subject = "Physics", Time = "3PM - 4:30PM", UniqueId = "53913"},
                                        new ClassSubject() {Professor = "Dr. George Berry", Subject = "Math", Time = "1PM - 2:00PM", UniqueId = "52973"}
                                    };
            foreach (var p in People)
            {
                p.ClassList = new ObservableCollection<ClassSubject>(classSchedule);
            }
        }
  
    private void PeopleGrid_RowIsExpandedChanging(object sender, Telerik.Windows.Controls.GridView.RowCancelEventArgs e)
        {
            var methodcalled = "Row Expanded";
        }


The event handler PeopleGrid_RowIsExpandedChanging was never called when I expanded a particular row.

0
Top Gun
Top achievements
Rank 1
answered on 06 May 2011, 12:45 AM
I figured it out.  The grid has a list of Person objects.  Each Person has a list of objects <ClassSubject> .  When I click on the "+ sign" Expand button, the row expands and displays objects <ClassSubject>.

The Person object has an observable collection:

private ObservableCollection<ClassSubject> _classList;
       public ObservableCollection<ClassSubject> ClassList
       {
           get { return _classList; }
           set { _classList = value; }
       }

The View (RadGrid) will call the get attribute on the ClassListProperty when the row needs to expand.  So in the get "getter" of ClassList you can put a method to make a database call.

private ObservableCollection<ClassSubject> _classList;
       public ObservableCollection<ClassSubject> ClassList
       {
           get
          {
          CALLDBHERE();  //Make the call here 
          return _classList; 
            }
           set { _classList = value; }
       }
0
Yordanka
Telerik team
answered on 06 May 2011, 08:31 AM
Hi Top Gun,

We have already replied to the other forum thread started by you.
 
Kind regards,
Yordanka
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
Top Gun
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Top Gun
Top achievements
Rank 1
Share this question
or