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

Loading Row Detail Dynamically

3 Answers 253 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kelly
Top achievements
Rank 1
Kelly asked on 20 Sep 2011, 10:20 PM
I need to load detail data on-demand when I expand a row. I patterned my application after the sample provided in this thread: http://www.telerik.com/community/forums/silverlight/gridview/load-on-demand-gridview.aspx. I establish a Loaded handler in the HierarchyChildTemplate.

<telerik:RadGridView.HierarchyChildTemplate>
    <DataTemplate>
        <telerik:RadGridView x:Name="DetailGrid" DataContext="x:Null" ShowGroupPanel="False" Loaded="DetailGrid_Loaded" AutoGenerateColumns="False">
            <telerik:RadGridView.Columns>
                .
                .
                .
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
    </DataTemplate>
</telerik:RadGridView.HierarchyChildTemplate>

and load the detail rows in that handler:

private void DetailGrid_Loaded(object sender, RoutedEventArgs e)
 {
     DetailGrid = (RadGridView)sender;
     SelectedEvent = (EventMaster)DetailGrid.ParentRow.DataContext;

     //  Go make round trip to get detail data and set in DetailGrid.ItemsSource
     //  when round trip returns.
 }

So far, so good. The problem is that the Loaded event only fires the first time the row is expanded. What do you do if your detail data is also dynamic, and you want to reload it each time the row is expanded, or, say, if you just want to refresh it in response to user input?
I found the LoadingRowDetails event in the doc, which says it will fire "the very first time the row details are about to be shown. Once this event has been fired, it will never fire again for that row. However, if the row is recycled and then realized, it starts its "life" again, this event will be fired again the first time the details are about to be shown."

I think this is related, although I'm not using the LoadingRowDetails event, and never got it to fire when I tried it. I have no idea what "if the row is recycled and then realized" means. How do I reset the details so the event fires when the row is expanded the 2nd through nth time?

Another aspect of the problem is this: in general, how can you find a given row's detail grid? I can't even find a Rows collection.

Thank you,

KO

3 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 21 Sep 2011, 03:54 PM
Hello Kelly,

There seems to be some kind of misunderstanding. Hierarchical GridView and Row Details are two completely different things and they have absolutely nothing to do with each other. Please, read the two links that I have provided -- they will answer a lot of questions.

If you decide to use the RowDetails feature (which I recommend for your case), you can attach to the RowDetailsVisibilityChanged event which will be fired each time the user expands or collapses the row details. You can check this from the event arguments by reading e.Visibility. Then you can load your data each time a row detail is expanded. If you need to locate a certain control inside the row details template, you can take a look at this article

I hope this helps. Let me know if there are problems.

Kind regards,
Ross
the Telerik team

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

0
mshirey
Top achievements
Rank 1
answered on 10 Jul 2013, 08:24 PM
Hi, I know this is an older post, but I ran across it while searching for an answer to a similar issue.  My solution appears to be the same as what you're describing.  I'm hooking into "RowDetailsVisibilityChanged" and using "e.NewVisibility" to tell when it's opening vs. closing... unfortunately, this seems to also be triggered when the details control is scrolled into view.  So if I have a long list of expanded details rows that have expanded out of view and I then use the scroll bar to scroll down to them, this even is again fired and the details loaded again.  With the amount of scrolling being done this is far from ideal... is there a better way to do this, or is there a way I can prevent this event from being fired when it's scrolled into view vs. expanded?

Thanks,

-- Matthew
1
Rossen Hristov
Telerik team
answered on 11 Jul 2013, 07:39 AM
Hi,

That is correct and is caused by row virtualization. You can turn row virtualization off by setting RadGridView.EnableRowVirtualization to false.

Regards,
Rossen Hristov
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Fernando
Top achievements
Rank 1
commented on 10 Jul 2022, 04:35 PM

Thanks, Rossen!

Scrolling Up will trigger the LoadingRowDetails event if EnableRowVirtualization is set to True!

Tags
GridView
Asked by
Kelly
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
mshirey
Top achievements
Rank 1
Share this question
or