我有一个动态构建的Kendo菜单。
@(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);
}
})
并调用此函数:
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);
}
});
}
}
我想根据用户的角色隐藏菜单。但.SecurityTrimming(s => s.HideParent(true))
并未隐藏用户未获得授权的菜单。
构建动态菜单还是没有sitemap
?