Hi
Handoyo,
Thanks
for contacting Syncfusion support.
Your
requirement of “Display the Menu items based on Role” can be achieved by
filtering the list based on Role field. We have used Generic
Drop Down, based on this DropDown value the Menu items will be displayed in the
web page. Please refer the following code snippet.
<code>
[controller]
[HttpPost]
public ActionResult
Index(string myDropDown)
{
List<GenericListMenu>
newlist = new MenuDataContext().GenericListMenu;
List<GenericListMenu>
result1 = new List<GenericListMenu>();
if (myDropDown == "Team
Leader")
{
result1 = newlist.Where(c => c.Role == "TL").ToList<GenericListMenu>();
}
else
{
result1 = newlist.Where(c => c.Role == "TM").ToList<GenericListMenu>();
}
ViewData["MenuData"] = result1;
return View(ViewData["MenuData"]);
}
[View[
@{ Html.Syncfusion().Menu("myMenu")
.DataSource((System.Collections.IEnumerable)ViewData["MenuData"])
.BindTo(bind => bind
.Id("ID")
.ParentId("ParentID")
.Text("MenuText")
)
.Render();}
</code>
We have also prepared a simple sample to show case this
behavior. It can be downloaded from the below given link
Menu_DB.zip
Please let us know if you have further queries.
Warm Regards,
Gurunathan