We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Generate menu and set visibility

Thread ID:

Created:

Updated:

Platform:

Replies:

110666 Aug 20,2013 03:14 AM Sep 18,2013 09:09 AM ASP.NET MVC (Classic) 3
loading
Tags: Tools
handoyo
Asked On August 20, 2013 03:14 AM

Hi,first of all thanks for the great component.Is it possible to generate menu from database and set the visibility of each menu item based on role?Are there any example how to create it?Thanks

Gurunathan A [Syncfusion]
Replied On August 23, 2013 06:30 AM

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


handoyo
Replied On September 17, 2013 09:24 AM

Hi there,i have downloaded the sample code,but it givex me error when i want to run it,it says the ToolController and ToolFeatures not available.Thanks

Gurunathan A [Syncfusion]
Replied On September 18, 2013 09:09 AM

Hi Handoyo,

We regret for the inconvenient caused. We suspect that the error might have occurred due to improper deletion of “ToolsController page”. Please download the modified sample from the link given below,

 Menu_DB.zip

Warm Regards,

Gurunathan


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;