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

[Solved] How to Implement Many to Many Editing in RadGrid?

2 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
tony
Top achievements
Rank 1
tony asked on 11 Aug 2013, 05:28 PM
How do I implement many to many editing in radgrid using entity framework and declarative techniques? I have looked all over for examples.

my case is very simple with the following tables: Student, Class, StudentClass with StudentClass being strictly defined by Student.ID, and Class.ID

Entity framework turns this into Students with a Classes navigation property and Classes with Students navigation property.

In radgrid I want to display the classes for a given student, thus creating a localized master-detail or 1 to many view. unfortunately I can't pull it off, perhaps because not fully understanding the navigation properties and independent association, StudentClass.

I created an EntityDataSource against Students. I associated it with the StudentCourseRadGrid. in Master table View --> Columns, I have a bound ID (Student) column, and a dropdown Courses column. After that, things fall apart. Once I select the student, its id appears in the grid, but not his courses.

And then, of course, I want to be able to crud the StudentClass relationship. I fully expect to handle the radgrid_insert event which I have done easily in 1 to many scenarios.

this is the section giving me the most difficulty - it is wrong - very wrong.

<telerik:GridDropDownColumn DataSourceID="Students"
         FilterControlAltText="Filter Materials column" HeaderText="Courses"
         ListTextField="Course.Name" ListValueField="Course.ID"
         UniqueName="Courses" DataField="ID">
</telerik:GridDropDownColumn>

I have tried many other permutations involving DataSourceID, ListTextField, ListValueField, and DataField, using Courses reversed with Students,without success. The only examples I have seen are hierarchical but I don't consider my situation hierarchical and it only confuses matters.

Any help is appreciated.

PS - after thinking about this, I believe that I tried to oversimplify the problem. 1 dataset is required to display the Student, 1 dataset - perhaps a navigation property though not sure how - is needed for the student's Classes, and 1 dataset is required to provide domain values for the StudentClass relationship should tuples be added. it will require more custom coding than wanted, but it is the logical, approach. I would be interested in something more efficient but for now I don't see it.




2 Answers, 1 is accepted

Sort by
0
tony
Top achievements
Rank 1
answered on 12 Aug 2013, 12:39 AM
in simplifying the exercise, I have focused just on the task of displaying the StudentClass data. I believe that a separate custom query is required. it is too bad that there is no way to take advantage of the independent association class to address this matter. I will implement NeedDataSource, or something else to retrieve the StudentClass data.
0
Tsvetoslav
Telerik team
answered on 14 Aug 2013, 09:35 AM
Hi Tony,

It is possible to accomplish it declaratively. Attached is a small sample.
 
Regards,
Tsvetoslav
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.
Tags
Grid
Asked by
tony
Top achievements
Rank 1
Answers by
tony
Top achievements
Rank 1
Tsvetoslav
Telerik team
Share this question
or