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

How to create NestedViewTemplate and get Primary Key of parent item

1 Answer 140 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gaurav
Top achievements
Rank 1
Gaurav asked on 27 Jun 2014, 08:23 PM
I am trying to create a two level nested grid. First level RadGrid will have list of all users (name, ID, email address etc.). Second level grid nested inside the first grid will have list of departments that user has access to.

I created this grid using this example: http://www.telerik.com/help/aspnet-ajax/grid-nestedviewtemplate.html

However I run into couple of issues

1) When I expand User1, it correctly displays the list of departments he has access to (e.g. Department1 and Department2).

>User1
--Department1
--Department2
>User2


When I expand User2, the nested grid displays the list of departments User2 has access to (Department3 and Department4), but it also displays the same under User1.


>User1
--Department3
--Department4
>User2
--Department3
--Department4


2) The second issue I need help with is the Primary Key of parent record. For example, if I need to add a new department under User1, the form field with User1's primary key should already be populated. How do I get that value?








1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 02 Jul 2014, 11:43 AM
Hi Gaurav,

To achieve this requirement you can use DetailTables provided by RadGrid and bind them either declaratively:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/declarative-relations/defaultcs.aspx
Or programmatically:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/programmatic-hierarchy/defaultcs.aspx

Alternatively, you can use NestedViewTemplates for complete customization:
http://demos.telerik.com/aspnet-ajax/grid/examples/hierarchy/hierarchy-with-templates/defaultcs.aspx


Depending on your chosen approach, we can suggest a proper solution for the second enquiry.

Looking forward to your reply.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Gaurav
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or