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

[Solved] how to populate the hierarchy data dynamically on demand?

4 Answers 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
haiwen
Top achievements
Rank 1
haiwen asked on 14 May 2009, 09:52 PM

hello, everyone

I am using a NestedViewTemplate to dispay hierarchy structure of data in the Gridview. it's working well except too slow for large dataset even with paging.

Is it possible to load the detail data on server side on demand?

I cann't declare the relationship like showed in the samples since the grid is quite generic.

Is it possible to postback to server when the user try to expand the parent row and populated the nested data on demand?

the partial codes look like:
<MasterTableView>
    <NestedViewTemplate>
        <fieldset>
            <asp:GridView id="detail" runat="server" AutoGenerateColumns="true"></asp:GridView>
        </fieldset>
    </NestedViewTemplate>

Thanks a lot for your help!

haiwen

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 15 May 2009, 04:19 AM
Hello Haiwen,

You can try out teh following code to populate your on expanding the parent row:
c#:
protected void RadGrid1_PreRender(object sender, EventArgs e) 
    { 
        foreach (GridDataItem item in RadGrid1.MasterTableView.Items) 
        { 
            if (item.Expanded) 
            { 
                foreach (GridNestedViewItem item1 in RadGrid1.MasterTableView.GetItems(GridItemType.NestedView)) 
                { 
                    GridView grid = (GridView)item1.FindControl("detail"); 
                    grid.DataSourceID = "SqlDataSource1"
                } 
            }             
        }   
    } 

Thanks
Princy.
0
haiwen
Top achievements
Rank 1
answered on 15 May 2009, 01:50 PM
Hello, Princy,

Thank you so much for your reply,

From your codes we can see that all of nested item will be populated, that will get same result as my current way.

Is it possible to catch the expanding event and only populate 1 nested item at a time?

Thanks again,

haiwen
0
Accepted
Yavor
Telerik team
answered on 18 May 2009, 11:21 AM
Hi haiwen,

One possible option in this case would be to use the DetailTableDataBind event handler. There, you can determine the level of the hierarchy, and pass the appropriate data.
I hope this suggestion gets you started properly.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
haiwen
Top achievements
Rank 1
answered on 20 May 2009, 04:33 PM
Thanks a lot, Yavor
Yes, after swich to the detail table, it works for me now.

haiwen
Tags
Grid
Asked by
haiwen
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
haiwen
Top achievements
Rank 1
Yavor
Telerik team
Share this question
or