Hi,
I'm trying to create a menu in my MVC 4 _Layout.cshtml file.
I started from the example and I hacked it up to show the structure I want. The problem is that when I use the syntax:
children.Add().Text("Application Home").Action("Index", "Home");
Sometimes the menu item is placed correctly with the action wired up. Other times the action appears to be causing some kind of error, (page compiles fine), but the item is not shown. If I remove the Action method, the
item shows up where it's supposed to.
I've attached the entire menu code. Can someone please help?
I'm trying to create a menu in my MVC 4 _Layout.cshtml file.
I started from the example and I hacked it up to show the structure I want. The problem is that when I use the syntax:
children.Add().Text("Application Home").Action("Index", "Home");
Sometimes the menu item is placed correctly with the action wired up. Other times the action appears to be causing some kind of error, (page compiles fine), but the item is not shown. If I remove the Action method, the
item shows up where it's supposed to.
I've attached the entire menu code. Can someone please help?
001.
@(Html.Kendo().Menu()
002.
.HighlightPath(true)
003.
.Name("Menu")
004.
.Items(items =>
005.
{
006.
items.Add()
007.
.Text("Home")
008.
.Items(children =>
009.
{
010.
children.Add().Text("Website Home");
011.
children.Add().Text("Application Home").Action("Index", "Home");
012.
});
013.
014.
items.Add()
015.
.Text("Company")
016.
.Items(children =>
017.
{
018.
children.Add().Text("Events")
019.
.Items(innerChildren =>
020.
{
021.
innerChildren.Add().Text("List");
022.
//.Action("Index", "CompanyEvents");
023.
innerChildren.Add().Text("Calendar View");
024.
//.Action("Calendar", "CompanyEvents");
025.
});
026.
027.
children.Add().Text("Departments");
028.
//.Action("Index", "Department");
029.
030.
031.
children.Add().Text("Configure")
032.
.Items(innerChildren =>
033.
{
034.
innerChildren.Add().Text("Benefit Year");
035.
//.Action("Index", "BenefitYear");
036.
innerChildren.Add().Text("Employee Types").Action("Index", "EmployeeType");
037.
innerChildren.Add().Text("Holidays").Action("Index", "Holiday");
038.
innerChildren.Add().Text("Job Codes").Action("Index", "JobCode");
039.
innerChildren.Add().Text("PTO Request Status Codes").Action("Index", "RequestStatusCode");
040.
innerChildren.Add().Text("PTO Acrual").Action("Index", "PTOAcrual");
041.
});
042.
043.
});
044.
045.
items.Add()
046.
.Text("Employee")
047.
.Items(children =>
048.
{
049.
children.Add().Text("Employee Search");
050.
//.Action("Index", "Employee");
051.
children.Add().Text("Employee Grid");
052.
//.Action("IndexGrid", "Employee");
053.
054.
children.Add().Text("PTO Request")
055.
.Items(innerChildren =>
056.
{
057.
innerChildren.Add().Text("List").Action("Index", "PTORequest");
058.
innerChildren.Add().Text("New PTO Request").Action("Create", "PTORequest");
059.
});
060.
061.
children.Add().Text("Edit Personal Data").Action("Edit", "Employee", new { id = EmpId });
062.
children.Add().Text("Employee Profile")
063.
.Items(innerChildren =>
064.
{
065.
innerChildren.Add().Text("List").Action("Index", "EmployeeProfile");
066.
//innerChildren.Add().Text("Edit my Profile").Action("Edit", "EmployeeProfile", new { id = EmpProfileId });
067.
innerChildren.Add().Text("Edit my Profile").Action("Edit", "EmployeeProfile");
068.
});
069.
070.
children.Add().Text("Sanction")
071.
.Items(innerChildren =>
072.
{
073.
innerChildren.Add().Text("List").Action("Index", "Sanction");
074.
innerChildren.Add().Text("New Sanction").Action("Create", "Sanction");
075.
});
076.
077.
children.Add().Text("Attendance Log")
078.
.Items(innerChildren =>
079.
{
080.
innerChildren.Add().Text("List").Action("Index", "AttendanceLog");
081.
innerChildren.Add().Text("New Attendance Log").Action("Create", "AttendanceLog");
082.
});
083.
084.
children.Add().Text("Timesheet")
085.
.Items(innerChildren =>
086.
{
087.
innerChildren.Add().Text("List").Action("Index", "TimeSheet");
088.
innerChildren.Add().Text("List (Grid)").Action("IndexGrid", "TimeSheet");
089.
innerChildren.Add().Text("New Timesheet").Action("Create", "Timesheet");
090.
});
091.
092.
});
093.
094.
095.
items.Add()
096.
.Text("Admin").HtmlAttributes(new { id="admin"})
097.
.Items(children =>
098.
{
099.
children.Add().Text("Company").Action("Index", "Company");
100.
children.Add().Text("Subscription Level").Action("Index", "SubscriptionLevel");
101.
children.Add().Text("Subscription Limits").Action("Index", "SubscriptionLimit");
102.
children.Add().Text("PTO Pool Type").Action("Index", "PTOPoolType");
103.
children.Add().Text("Absence Code").Action("Index", "AbscenceCode");
104.
children.Add().Text("Timesheet Status Codes").Action("Index", "TimesheetStatusCode");
105.
children.Add().Text("Activity Log").Action("Index", "ActivityLog");
106.
children.Add().Text("Release History").Action("Index", "ReleaseHistory");
107.
children.Add().Text("Report List").Action("Index", "Report");
108.
children.Add().Text("Suggestion List").Action("Index", "UserSuggestion");
109.
children.Add().Text("Create Employee w/o User").Action("Create", "Employee");
110.
}).Enabled(false);
111.
112.
//items.Add().Text("About");
113.
//items.Add().Text("Contact");
114.
})
115.
)