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

NestedViewTemplate with Controls added programmatically while binding

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Itye
Top achievements
Rank 1
Itye asked on 06 Jul 2011, 04:28 PM
Hi,

I have a simple RadGrid control.
For each data item in the Datasource I create a User Control.
The user control is determined at runtime according to the data-item (or data item id).
I use LoadControl function to load the control.

I want to add this control as a nested view template, so I can collapse/expand each row and edit the different controls.
Once I finish editing the controls - (all in client side), I hit a save button to persist all the information to database.

I will have to loop through the rows, get the user-control and execute a save function in it.

What would be the best practice to achieve this?
I started by adding NestedViewTemplate  with a container panel to hold the various user controls.
This is how it looks like:
<MasterTableView AutoGenerateColumns="False" DataKeyNames="Id"  GroupLoadMode="Client" HierarchyLoadMode="Client">
                <NestedViewTemplate>
                    <asp:Panel runat="server" ID="configControlContainer" CssClass="viewWrap" Visible="true">
                    </asp:Panel>
                </NestedViewTemplate>
                <Columns>
.
.
.

Thank you,

-Itye

3 Answers, 1 is accepted

Sort by
0
Mira
Telerik team
answered on 11 Jul 2011, 03:16 PM
Hello Itye,

In order to implement the desired functionality, I recommend that you load the usercontrols on ItemCreated and populate them with data on ItemDataBound. You can examine this help topic to see the major differences between ItemCreated and ItemDataBound events.

Please check out the Traversing detail tables/items in Telerik RadGrid help topic to learn how to access the nested table views.

I hope this helps.

Greetings,
Mira
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Trung Nguyen
Top achievements
Rank 1
answered on 02 Aug 2015, 08:53 AM
same problem, help me :(
0
Eyup
Telerik team
answered on 06 Aug 2015, 06:40 AM
Hello Trung,

Could you elaborate on your requirement? What exactly is the problem you mentioned? Generally, you can examine the following live sample for implementing a NestedViewTemplate:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchy-with-templates/defaultcs.aspx

Regards,
Eyup
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Itye
Top achievements
Rank 1
Answers by
Mira
Telerik team
Trung Nguyen
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or