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

Hiding empty menu items

1 Answer 187 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Assaf
Top achievements
Rank 1
Assaf asked on 19 Oct 2012, 01:23 PM
Hi,

I'm using the Kendo.Mvc.Menu with a site map and security trimming.
My problem is that when all sub items of a menu item are trimmed, the parent item is still being displayed.

I've found an answer to a similar question regarding the Telerik.Menu, on this thread.
However, I could not find the equivalent in the Kendo framework to this line:

<% var navAuthorization = Telerik.Web.Mvc.Infrastructure.ServiceLocator.Current.Resolve<Telerik.Web.Mvc.Infrastructure.INavigationItemAuthorization>(); %>

Best regards,

Assaf

1 Answer, 1 is accepted

Sort by
0
Lauri
Top achievements
Rank 1
answered on 17 May 2013, 03:12 AM
Hi,

This might come a bit late, but for others searching for the same thing:
@{var navAuthorization = Kendo.Mvc.Infrastructure.DI.Current.Resolve<Kendo.Mvc.Infrastructure.INavigationItemAuthorization>(); }
and the menu part
@Html.Kendo().Menu().Name("Menu").BindTo("sitemap", (item, siteMapNode) =>
{
var hasAccessible = true;
 foreach (var children in siteMapNode.ChildNodes)
 {
 hasAccessible = false;
 if (children.IsAccessible(navAuthorization, ViewContext))
 {
 hasAccessible = true;
break;
 }
}
 item.Visible = hasAccessible;
 })
Tags
Menu
Asked by
Assaf
Top achievements
Rank 1
Answers by
Lauri
Top achievements
Rank 1
Share this question
or