Load data in a nestedview iten when the item expand

2 posts, 0 answers
  1. Anders
    Anders avatar
    30 posts
    Member since:
    Jul 2013

    Posted 27 Nov 2013 Link to this post

    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
  2. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 29 Nov 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top