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

how to call on button click event the RadGrid1_RowDetailsVisibilityChanged event

4 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
kumar p
Top achievements
Rank 1
kumar p asked on 26 May 2010, 06:57 AM
hi,
 i am  developing an nested  RadGrid . in my  first  column i have  place  an button . so that once  user  clicks on that button i need  to call the  RowDetailsVisibilityChanged event
 so that i can get the row unquie keyID  there based on that  i will be  retrieving  further  records  from the DB.
the below  code  shows  how  i used  to  do in  microsoft silverlight 4. the same  concept i need  to archive in  telerik control
i  tried  chaging  RowDetailsVisibilityMode ="Collapsed", VisibleWhenSelected, Visible in xaml   but still i am not able  to able the   

RowDetailsVisibilityChanged event

 here i  am using for four  RadGrid placed inside each other. this is  the  concept  i am using  to achive.

  <telerik:RadGridView.RowDetailsTemplate>
                <DataTemplate>
// here i am placing  my second datagrid.
             </DataTemplate>
</telerik:RadGridView.RowDetailsTemplate> 


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


private void ExpandLevel1_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Button btnExpandCollapse = sender as Button;
                Image imgScore = (Image)btnExpandCollapse.FindName("img1");
                // the original source is what was clicked.  For example  
                // a button.
                DependencyObject dep = (DependencyObject)e.OriginalSource;
                // iteratively traverse the visual tree upwards looking for
                // the clicked row.
                while ((dep != null) && !(dep is DataGridRow))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }

                // if we found the clicked row
                if (dep != null && dep is DataGridRow)
                {
                    // get the row
                    DataGridRow row = (DataGridRow)dep;
                    // change the details visibility
                    if (row.DetailsVisibility == Visibility.Visible)
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/la1.png", UriKind.Relative));
                        row.DetailsVisibility = Visibility.Collapsed;
                    }
                    else
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/a2.png", UriKind.Relative));
                        row.DetailsVisibility = Visibility.Visible;
                    }
                }
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }

 now. once  user  clicks the button   i need to call the RowDetailsVisibilityChanged event  which is not  happening  and
also perform expand/ collpase operation  clicking on the button

 any help   how  to achive this   would be  greatly appreciated.

 thanks
 kumar

4 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 26 May 2010, 07:13 AM
Hello,

You can use the same approach with RadGridView however you will need to change DataGridRow to GridViewRow.


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
kumar p
Top achievements
Rank 1
answered on 26 May 2010, 07:26 AM
thanks  for the repay
 i did  the  changes  still  same issue still not able  to   call the 

RadGrid1_RowDetailsVisibilityChanged event


try
            {
               
                Button btnExpandCollapse = sender as Button;
                Image imgScore = (Image)btnExpandCollapse.FindName("imgLevel1");
                // the original source is what was clicked.  For example  
                // a button.
                DependencyObject dep = (DependencyObject)e.OriginalSource;
                // iteratively traverse the visual tree upwards looking for
                // the clicked row.
                while ((dep != null) && !(dep is RadRowItem ))
                {
                    dep = VisualTreeHelper.GetParent(dep);
                }

                // if we found the clicked row
                if (dep != null && dep is RadRowItem)
                {
                    // get the row
                    RadRowItem row = (RadRowItem)dep;
                   
                    // change the details visibility
                    //.Visibility = Visibility.Collapsed;
                   
                    if (row.RowIndicatorVisibility == Visibility.Visible)
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/down_side.png", UriKind.Relative));
                        row.RowIndicatorVisibility = Visibility.Collapsed;
                    }
                    else
                    {
                        imgScore.Source = new BitmapImage(new Uri("/Images/left_side.png", UriKind.Relative));
                        row.RowIndicatorVisibility = Visibility.Visible;
                    }
                }
              
            }

            catch (Exception ex)
            {
                throw ex;
            }

 thanks
0
Accepted
Vlad
Telerik team
answered on 26 May 2010, 07:32 AM
Hi,

As I said in my reply you should use DetailsVisibility with GridViewRow not RowIndicatorVisibility with RadRowItem.

Sincerely yours,
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
kumar p
Top achievements
Rank 1
answered on 26 May 2010, 09:07 AM
 thanks   issue is fixed
Tags
GridView
Asked by
kumar p
Top achievements
Rank 1
Answers by
Vlad
Telerik team
kumar p
Top achievements
Rank 1
Share this question
or