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

Disable menu item after accessing page

1 Answer 138 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Menashay
Top achievements
Rank 1
Menashay asked on 01 Jan 2014, 02:57 AM
I have a kendo menu on the _LoginPartial page.
The menu has 'links' to various actions for instance:
 @(Html.Kendo().Menu()
    .Name("MainMenu")
    .Items(items =>
  {
     items.Add()
    .Text("Manage Clients")
   .Action("Index", "Clients")
... and so forth

This menu is showing if the account is authenticated.
So that users do not keep clicking on the same menu item after they got into their desired page I want to  disable the relevant menu item.
In the above mentioned example after users click 'manage clients' the action ("Index", "Clients") will be disabled; when users get out of that page
('manage clients') that same menu item will be enabled again.
How can I accomplish this?

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 02 Jan 2014, 11:17 AM
Hello Menashay,

You can add an Enabled() property to each Menu item, which depends on a boolean parameter based on the current controller and view names. Those can be passed from the Controller, e.g. in the ViewBag, or retrieved from the ViewContext / HttpContext.

http://stackoverflow.com/questions/6852979/get-current-controller-in-view

items.Add()
   .Text("Home")
   .Action("Index", "Home")
   .Enabled(ViewBag.ControllerName != "Home" || ViewBag.ActionName != "Index");


Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Menu
Asked by
Menashay
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or