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

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

7 Answers 85 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Stephen
Top achievements
Rank 1
Stephen asked on 12 Jul 2012, 02:42 PM
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.

7 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 13 Jul 2012, 09:17 AM
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 >>

0
Stephen
Top achievements
Rank 1
answered on 13 Jul 2012, 04:39 PM
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;
}
0
Dimitrina
Telerik team
answered on 17 Jul 2012, 07:54 AM
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.

0
Stephen
Top achievements
Rank 1
answered on 17 Jul 2012, 12:06 PM
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.
0
Accepted
Dimitrina
Telerik team
answered on 17 Jul 2012, 12:08 PM
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.

0
Stephen
Top achievements
Rank 1
answered on 17 Jul 2012, 12:16 PM
Perfect!  Thank you.
0
Hemanth
Top achievements
Rank 1
answered on 21 Nov 2012, 04:32 AM
Superb....!!

Same problem i was facing. now it working

Thanks alot, for your work
Tags
GridView
Asked by
Stephen
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Stephen
Top achievements
Rank 1
Hemanth
Top achievements
Rank 1
Share this question
or