I have a Kendo menu that is built dynamically.
@(Html.Kendo().Menu() .Name("menu") .HtmlAttributes(new { @class = "menu-top", styles = "max-height:55px" }) .SecurityTrimming(s => s.HideParent(true)) .Items(menu => { foreach (var item in Model.Where(m => m.mnu_Parent_ID == null)) { var builder = menu.Add().Text(item.mnu_Title); addChildren(builder, item, Model); } })
and calls this function:
public void addChildren(MenuItemBuilder builder, workflow.ViewModels.Home.MenuViewModel item, List<workflow.ViewModels.Home.MenuViewModel> items) { var children = items.Where(m => m.mnu_Parent_ID == item.mnu_ID); if (children != null) { builder.Items(menuItems => { foreach (var child in children) { var menuItem = menuItems.Add().Text(child.mnu_Title).Action(child.mnu_Action,child.mnu_Controller).LinkHtmlAttributes(new { onclick = "ShowRequestForm('" + child.mnu_Title + "','" + child.mnu_URL + "'," + child.mnu_ID + ",-1," + child.mnu_flowID + ",'" + child.mnu_OpenWindow + "'," + prs_ID + ",-1,-1 );" }); addChildren(menuItem, child, items); } }); } }
I want to hide the menus base on user's roles. But the .SecurityTrimming(s => s.HideParent(true))
does not hide the menus that user is not authorized for them. Is the problem for building dynamic menu or not having the sitemap
?
0 comments:
Post a Comment