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

Cascading dropdowns with many-to-many relationship

3 Answers 204 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 05 Aug 2013, 06:46 PM
Hi all,

I'm using the ASP.NET wrapper, but I figured this question is general enough it would be better posted here.

I'd like to create a cascading dropdown structure for a many-to-many data relationship. An example structure similar to my data:
Course model (id CourseID) can have many Students.
Student model (id StudentID) can have many Courses.
A third table (CourseStudent) links the two IDs, meaning that neither model has an ID reference to the other.

Is there any easy way to do this? Using the "CascadeFrom" method during definition works for one-to-many relationships, but not in this case. Do I need to include a computed property on one of my models in order to have the ID?

Thanks,
Jeff

3 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 07 Aug 2013, 03:25 PM
Hi Jeff,

I would suggest you to use the dataSource filter in order to get only the values that match your criteria. You can use the operator "and" to filter for certain course and student.

I have prepared an example showing a possible implementation:

http://jsbin.com/etonib/1/edit
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeff
Top achievements
Rank 1
answered on 07 Aug 2013, 03:32 PM
Kiril,

Thank you for the reply, but I don't see how your case could apply to using the CascadeFrom method, or the MVC wrappers at all for that matter. What you're suggesting would require listening to the change event of one dropdownlist and performing the cascade manually, which I'm already doing anyways. I was asking if there was an easy way to enable cascading in a many-to-many relationship (because it's so easy for one-to-many).

Regards,
Jeff
0
Kiril Nikolov
Telerik team
answered on 12 Aug 2013, 06:47 AM
Hello Jeff,

Indeed it will require listening to the change event and implementing the cascading manually. At the moment there is no built-in functionality that can fulfill this requirement out-of-the-box. If you think that this should be added to Kendo UI you can always submit it as a suggestion in our feedback forums.
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
DropDownList
Asked by
Jeff
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Jeff
Top achievements
Rank 1
Share this question
or