GridView w/ TabControl: Need to know values in selected row to populate the tab correctly

8 posts, 1 answers
  1. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 12 Jul 2012 Link to this post

    I have a silverlight page.  The main page has the gridview, with a tab control in the GridViewToggleRowDetailsColumn.  It has an exposed property called RequestId.  I have a second xaml in the same project, which is the content of the first tab in the Tab Control.  This was done just like in your Telerik.Windows.Examples.GridView.FirstLook.Example.

    First I tried using the GridView SelectionChanged event to look at the row and set the RequestId value.  The problem with that is that clicking directly on the toggle in the row doesn't select the row.  It just opens up the toggle, showing the TabControl.  If I select the row first, then click on the toggle, it works.  Problem is that I cannot implement it that way.

    So, I went hunting for other events on the GridView to find one that always triggers before it instantiates my Tab Content xaml.  I tried all of these and none of them executed at the time I need.

    RowIsExpandedChanged
    RowIsExpandedChanging
    RowDetailsVisibilityChanging
    GroupRowIsExpandedChanged
    GroupRowIsExpandedChanging

    What I really need is an event that is going to trigger, when the person clicks on the toggle in the row in the GridView that triggers one time before it opens the Tab Control, populating it with my xaml file content.  Once I am in the event, I need to get the row in the grid where the toggle button was clicked, in order to get that RequestId value.

    I have gone through the documentation, the sample project, and the forums looking for something I can use, but I can't find anything.  I assume this is a common thing that people do, so I must be missing something along the way.

    I did find the way to make it so only one row is expanded at once, using the RowDetailsVisibilityChanged event, which is good.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 13 Jul 2012 Link to this post

    Hi,

     Have you tried the RowDetailsVisibilityChanged event? In its arguments you can access the Row which visibility was changed.

    private void clubsGrid_RowDetailsVisibilityChanged(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
    {
                var row = e.Row;
    }
    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft banner
  4. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 13 Jul 2012 Link to this post

    RowDetailsVisibilityChanged actually happens after the event that opens up and populates the Tab Control.  So, I would click on the twisty and the Tab Control would open and populate, then this event would trigger.  I thought I should give RowDetailsVisibilityChanging another try and it works!  I think the first time I tried using this event, I wasn't accessing the row details properly.  So, your suggestion led me to the event I needed to use.

    This is what I am doing now:

    private void rgvMainGrid_RowDetailsVisibilityChanging(object sender, RowDetailsVisibilityChangingEventArgs e)
    {
        var _Row = e.Row.DetailsProvider.DataContext as RequestDetail;
     
        if (_Row != null)
        {
            _SelectedPerson = _Row.PersonId;
            _SelectedRequest = _Row.RequestId;
        }
    }

    I do have another related question.  How can I trigger the Tab Control to open just selecting a row, instead of making the user click on the twisty?  Here is my selection changed event:

    private void rgvMainGrid_SelectionChanged(object sender, SelectionChangeEventArgs e)
    {
        var _Row = (RequestDetail) rgvMainGrid.SelectedItem;
    }
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jul 2012 Link to this post

    Hi,

    I am glad that you have found the appropriate event.

    As to your current question - I am not sure that I understand it. May I ask you to explain in great details what do you mean by "How can I trigger the Tab Control to open just selecting a row, instead of making the user click on the twisty?"?

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 17 Jul 2012 Link to this post

    Sorry that was not very clear.  The grid view has rows and each row has a toggle (twisty) in it, which will open a nested tab control.  Right now, you have to click on the twisty to show or hide the tab control.  I would like it to open when I click on the row (anywhere on the row), as opposed to having to click right on the twisty itself.
  7. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 17 Jul 2012 Link to this post

    Hi,

    Thank you for clarifying.

    You could set the appropriate RowDetailsVisibilityMode for the GridView:

    RowDetailsVisibilityMode="VisibleWhenSelected"

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Stephen
    Stephen avatar
    43 posts
    Member since:
    Apr 2012

    Posted 17 Jul 2012 Link to this post

    Perfect!  Thank you.
  9. Hemanth
    Hemanth avatar
    24 posts
    Member since:
    Mar 2011

    Posted 20 Nov 2012 Link to this post

    Superb....!!

    Same problem i was facing. now it working

    Thanks alot, for your work
Back to Top
DevCraft banner