How can I collapse RowDetails?

15 posts, 0 answers
  1. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 29 Jun 2010 Link to this post

    I need to be able to collapse RowDetails after I expanded them. How do I do that. My RowDetaislVisibilityMode = "VisibleWhenSelected". Is there a programmatic approach? If so how?
    thakns
    --tolga
  2. Paul Dhingra
    Paul Dhingra avatar
    9 posts
    Member since:
    Jul 2009

    Posted 29 Jun 2010 Link to this post

    +1

    I too need to find a way to do this - the user can click in the GridViewToggleRowDetailsColumn to make the RowDetails visible or collapsed.

    However, I also need to be able to programmatically Collapse an expanded RowDetails area.



    Paul.
  3. DevCraft banner
  4. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 Jun 2010 Link to this post

    Hi Paul Dhingra,

    @Tolga

    VisibleWhenSelected means that they are visible when the row is selected and they are collapsed when the row is not selected. You can deselect a row and they will collapse. If you need to do things programmatically then do not set the RowDetailsVisibility mode of the grid but play with each row individually. You can do that via its DetailsVisibility property. Or you can use the special column GridViewToggleRowDetailsColumn. It is up to you.

    @Paul

    Each GridViewRow has a DetailsVisibility property that does exactly that. As a matter of fact, the toggle button of the GridViewToggleRowDetailsColumn is bound to this exact same property.

    @ Both

    Please, read the documentation. You will find everything what you need there.

    Greetings,
    Ross
    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
  5. Paul Dhingra
    Paul Dhingra avatar
    9 posts
    Member since:
    Jul 2009

    Posted 30 Jun 2010 Link to this post

    Understood, though I should have been more clear - I was already attempting to change the RowDetailsVisibility property, but my problem was that I couldn't determine how to find the GridViewRow in question.  My GridViewToggleRowDetailColumn's ExpandMode="Single", so I was hoping to be able to find the (selected? open?) gridviewrow and set the RowDetailsVisibility during certain event handling.  But all I can seem to locate is the SelectedItem (which is the data item itself, not the GridViewRow).

    In any case, I solved this using a different approach, the only time I can seem to find the specific GridViewRow is during the LoadingRowDetails event, so during that event I store a reference to the GridViewRow (e.row), and then use that to change the Visibility when needed.

    Paul.
  6. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2478 posts

    Posted 30 Jun 2010 Link to this post

    Hi Paul Dhingra,

    You can find the row from the SelectedItem like this:

    var selectedRow = this.radGridView.ItemContainerGenerator.ContainerFromItem(this.radGridView.SelectedItem) as GridViewRow;

    if (selectedRow != null)
    {
    //...
    }

    I hope this helps.

    Kind regards,
    Ross
    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
  7. Paul Dhingra
    Paul Dhingra avatar
    9 posts
    Member since:
    Jul 2009

    Posted 30 Jun 2010 Link to this post

    Yes, that absolutely does help!  I forgot about the ItemContainerGenerator, it's perfect for this (and several other) situations.

    Thanks!
  8. Tolga
    Tolga avatar
    28 posts
    Member since:
    Jun 2007

    Posted 30 Jun 2010 Link to this post

    Indeed, that does work, but now I have 2 more questions.

    1. How do I loop through all the rows in a GridView
    2. How do I trigger a "Row Click" event

    thanks

    --tolga
  9. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 01 Jul 2010 Link to this post

    Hi Tolga,

     Could you please share a bit more information about what you're trying to accomplish? Looping through UIElements and simulating user input is not a very efficient course of action. Perhaps we'll be able to reach your goals through alternate means.

    Sincerely yours,
    Yavor Georgiev
    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
  10. Gerry Connolly
    Gerry Connolly avatar
    16 posts
    Member since:
    Jan 2010

    Posted 18 Sep 2010 Link to this post

    Hi,

    I want to make row collapsed when RowDetails is visibile and Rowdetails should collapsed when row is visible.
    Is there any method to do it ?

    Please reply as soon as possible. I need it urgently.

    Thanks
  11. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 20 Sep 2010 Link to this post

    Hello Gerry Connolly,

     You can achieve your goal very easily by modifying the GridViewRow template. Please find attached a sample solution.

    Sincerely yours,
    Yavor Georgiev
    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
  12. Gerry Connolly
    Gerry Connolly avatar
    16 posts
    Member since:
    Jan 2010

    Posted 02 Oct 2010 Link to this post

    Hi,
    Yavor Georgiev
    your solution was good and working for me but now requrement has been changed.

    Now I need to open row details on row Click and Row should collpase

    I have tried with this in Rowloaded event but I am unable to understand why the code  is not reaching at event row_MouseLeftButtonUP on mouse click
    I can not use RowDetailsVisibilityMode="VisibleWhenSelected" because I want to open one rowdetails at a time though I can select mulitiple row
    Colud you suggest something the code is below :

     

     

    Private Sub GridView_RowLoaded(ByVal sender As Object, ByVal e As Telerik.Windows.Controls.GridView.RowLoadedEventArgs)

     

     

     

     

     

    Dim row As GridViewRow = TryCast(e.Row, GridViewRow
    If row IsNot Nothing Then  

     

    AddHandler row.MouseLeftButtonDown, AddressOf row_MouseLeftButtonUP 

     

     

     

    End If  

     

    End Sub

     

    Private Sub row_MouseLeftButtonUP(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)

     

    Dim row As GridViewRow = TryCast(sender, GridViewRow)

     

     

     

     

    If row IsNot Nothing Then

     

     

     

     

     

    row.DetailsVisibility = System.Windows.Visibility.Visible

     

     

     

     

    Dim dp As DetailsPresenter = New DetailsPresenter()

     

     

     

    dp.DetailsProvider = row.DetailsProvider 

     

     

    Dim dcp As DataCellsPresenter = New DataCellsPresenter()

     

    dcp.DataContext = row.DataContext

    dcp.Visibility = System.Windows.

     

     

    Visibility.Collapsed

     

     

    End If

     

     

     

     

     

     

     

     

     

     

    End Sub

     

     

     

     

  13. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 04 Oct 2010 Link to this post

    Hello Gerry Connolly,

     Please find attached an update to the sample solution. Unfortunately, your scenario is not achievable when DetailsVisibilityMode=VisibleWhenSelected. I have used the GridViewToggleRowDetails column instead.

    Regards,
    Yavor Georgiev
    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
  14. neo e
    neo e avatar
    19 posts
    Member since:
    Jul 2004

    Posted 12 Jan 2011 Link to this post

    To bind the rowdetailvisbility to a datamember. I create a custom column to acomplish this.

    public class GridViewToggleRowDetailDataColumn : GridViewDataColumn
       {        
           public static readonly DependencyProperty ToggleRowDetailDataMemberProperty =
               DependencyProperty.RegisterAttached("ToggleRowDeatilDataMember", typeof (string),
                                           typeof (GridViewToggleRowDetailDataColumn), new PropertyMetadata(string.Empty));
           public string ToggleRowDetailDataMember
           {
               get { return (string)GetValue(ToggleRowDetailDataMemberProperty); }
               set
               {
                   SetValue(ToggleRowDetailDataMemberProperty,value);
               }
           }
           public override FrameworkElement CreateCellElement(Telerik.Windows.Controls.GridView.GridViewCell cell, object dataItem)
           {
               var currenRow = cell.ParentRow as GridViewRow;
               if (null != currenRow && !string.IsNullOrEmpty(ToggleRowDetailDataMember))
               {
                   var binding = new Binding(ToggleRowDetailDataMember)
                                {
                                    Source = currenRow.DataContext,
                                    Mode = BindingMode.TwoWay,
                                    Converter = new BooleanToVisibilityConverter()
                                };
                   currenRow.SetBinding(GridViewRow.DetailsVisibilityProperty, binding);
               }
               return base.CreateCellElement(cell, dataItem);            
           }
            
       }
  15. Michael Gaigg
    Michael Gaigg avatar
    9 posts
    Member since:
    Dec 2009

    Posted 15 Feb 2011 Link to this post

    Thanks, that did the trick!
  16. Tajani
    Tajani avatar
    1 posts
    Member since:
    Jan 2013

    Posted 06 Feb 2014 in reply to Yavor Georgiev Link to this post

    the property ExpandMode="Single" can resolve the problem.

    <telerik:GridViewToggleRowDetailsColumn ExpandMode="Single" />

    Mohammed
Back to Top
DevCraft banner