This question is locked. New answers and comments are not allowed.
Hi guys,
I'm relatively new to MVC so please forgive me if I am conceptually a little wrong in any of my thinking.
The scenario:
I have 2 entities Department and MenuItem. (Note: Using EF4.1 code first to built entities. Not that that really effects this question)
Departments can have many MenuItems and a MenuItem can be owned by many Departments. Also a MenuItem may have another MenuItem as a parent.
Essentially what I am trying to do is have a dropdownlist of Departments and when a department is selected, the menu is 'rebound' to the correct set of MenuItems. A department could have up to 100 MenuItems and there could be 30 Departments.
I thought I could have had an action in my controller that would return JSON and then bind the JSON to the menu but I'm not sure I can do that? I have also tried passing a list of MenuItems (with a default selected department) via a ViewModel and used the model binding for the menu. From there I am not sure how I 'rebind' the menu to a new set of MenuItems when the selected department changes.
Any help or even a sample project would be amazing! I have looked through the demo's and looked at the examples that come with the MVC extensions and they still haven't helped.
I'm relatively new to MVC so please forgive me if I am conceptually a little wrong in any of my thinking.
The scenario:
I have 2 entities Department and MenuItem. (Note: Using EF4.1 code first to built entities. Not that that really effects this question)
Departments can have many MenuItems and a MenuItem can be owned by many Departments. Also a MenuItem may have another MenuItem as a parent.
public class Department{ public int DepartmentId { get; set; } public string Name { get; set; } public virtual ICollection<MenuItem> MenuItems { get; set; }}public class MenuItem{ public int MenuItemId { get; set; } public string Name { get; set; } [MaxLength] public string Url { get; set; } public virtual ICollection<Department> Departments { get; set; } public int? ParentId { get; set; } public virtual MenuItem ParentMenuItem { get; set; }}Essentially what I am trying to do is have a dropdownlist of Departments and when a department is selected, the menu is 'rebound' to the correct set of MenuItems. A department could have up to 100 MenuItems and there could be 30 Departments.
I thought I could have had an action in my controller that would return JSON and then bind the JSON to the menu but I'm not sure I can do that? I have also tried passing a list of MenuItems (with a default selected department) via a ViewModel and used the model binding for the menu. From there I am not sure how I 'rebind' the menu to a new set of MenuItems when the selected department changes.
Any help or even a sample project would be amazing! I have looked through the demo's and looked at the examples that come with the MVC extensions and they still haven't helped.