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

Load data in a nestedview iten when the item expand

1 Answer 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anders
Top achievements
Rank 1
Anders asked on 27 Nov 2013, 07:54 AM
At the moment I got a RadGrid with NestedViewTemplate. In the NestedViewTemplate I show some specific deatail information of the grid item. Thats workin OK. But the SQL for gathering all the data for both the RadGrid and for the NestedViewTemplate is quit heavy.

What I would like to do is to only load the data for the NestedViewTemplate when it's expanded. Loading the data using a separate call to the database, this means that I can simplify the SQL for the RadGrid.

How and where can I get access to event that fired when the NestedViewTemplate expand. And how do I reach RadGrid dataitem to get an ID for calling the SQL for loading the detail data?

Anders Pedersen

1 Answer, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 29 Nov 2013, 12:27 PM
Hello Anders,

You could achieve that by hooking the ItemCommand event handler and check whether the fired command is ExpandCollapse. There you could get the expanded GridDataItem and also you could access the NestedViewItem. Please check out the following code snippet.
protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.ExpandCollapseCommandName)
    {
        GridDataItem item = e.Item as GridDataItem;
        GridNestedViewItem nestedView = (item.OwnerTableView as GridTableView).GetItems(GridItemType.NestedView)[item.ItemIndex] as GridNestedViewItem;
    }
}


Regards,
Kostadin
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Anders
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Share this question
or