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

Master/detail using List Object (Nettier)

2 Answers 110 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Benny
Top achievements
Rank 1
Benny asked on 08 Feb 2008, 07:23 AM
Hi
At this moment I'm busy with evaluation the Telerik RadGrid in combination with NetTier. I'm trying to make the master/detail functionality working. I tried to do this at design time and in code. I looked at the examples but all of them used dataset instead of list of objects. I think that I make a mistake when setting the key for the master and for the detail in the relation ship The reason for this thinking is that I have the same problem when I add a combobox The combobox is filled but the underlaying value (the text instead of the id (FK)) is not showed (same for the detail)
I tried several things like getting the data for the master and for the details separatly or by using a deepload but nothing works (except for one time but instead of displaying the detail data the grid showed the master data in the detail data so it was a one on one situation but offcourse not correct) Below you will find the code of my last attempt (purly in code not in design) Maybe someone call tell me what is wrong or can give me an working example Thanks for your time.
The code is for binding modules (the master) to modules session (an in between table in the database) The key fields have the same name


//Get the data for the master

EducationModuleService serviceModule = new EducationModuleService();

TList<EducationModule> modules = serviceModule.GetAll();

grdvModules.DataSource = modules;

 

//Get the data for the Detail

EducationModuleSessionService serviceModuleSession = new EducationModuleSessionService();

TList<EducationModuleSession> moduleSession = serviceModuleSession.GetAll();

// bindingSourceModuleSession.DataSource = moduleSession;

//Create the Detail template

Telerik.WinControls.UI.

GridViewTemplate templateModuleSessions = new Telerik.WinControls.UI.GridViewTemplate();

templateModuleSessions.AllowAddNewRow =

false;

templateModuleSessions.DataSource = moduleSession;

templateModuleSessions.SummaryDisplayStyle = Telerik.WinControls.UI.

SummaryDisplayStyle.None;

 

//Add the detail template to the master template

this.grdvModules.MasterGridViewTemplate.ChildGridViewTemplates.AddRange(new Telerik.WinControls.UI.GridViewTemplate[] {

templateModuleSessions});

//Create the relation and add it the the RadGridView

GridViewRelation relation = new GridViewRelation(this.grdvModules.MasterGridViewTemplate);

relation.ParentColumnNames.Add(

"EducationModuleId");

relation.ChildColumnNames.Add(

"EducationModuleId");

relation.ChildTemplate = templateModuleSessions;

relation.RelationName =

"ModulesSessions";

this.grdvModules.Relations.Add(relation);


2 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 08 Feb 2008, 09:20 AM
Hello Benny,

Your hierarchy setup for RadGridView is absolutely right, with only the creation of GridViewTemplate has a small thing missing:

GridViewTemplate templateModuleSessions = new Telerik.WinControls.UI.GridViewTemplate(); 

should be:

GridViewTemplate templateModuleSessions = new Telerik.WinControls.UI.GridViewTemplate(grdvModules); 

For the new edition of RadGridView, after a template is added to ChildGridViewTemplates collection its Owner will be automatically changed.
I am sorry for the inconvenience and thank you for the feedback.

Greetings,
Julian Benkov
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Benny
Top achievements
Rank 1
answered on 08 Feb 2008, 09:34 AM

Thanks a lot for the fast answer Your answer solved the problem I'm finished now with the evalution and will recommend to buy the product.

Tags
GridView
Asked by
Benny
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Benny
Top achievements
Rank 1
Share this question
or