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

How to Create Dynamic Menu In MVC Razor Application

6 Answers 559 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Parikshit
Top achievements
Rank 1
Parikshit asked on 30 Jan 2012, 06:31 AM

How To Create Dynamic Menu using Kendo ui in MVC Razor Application..........

6 Answers, 1 is accepted

Sort by
0
aaaaaaaaaa
Top achievements
Rank 1
answered on 26 Aug 2016, 01:08 PM
Five years ago and Telerik doesn't have an answer?
0
Alex Hajigeorgieva
Telerik team
answered on 31 Aug 2016, 09:03 AM
Hello Wilfredo,

Occasionally, there are forum topics which remain unanswered - sometimes it is the client, who decided to close the thread, sometimes it is automatically closed by the system after a certain period of inactivity as it seems to have occurred in this case. The original question is in the wrong forum section - the Kendo UI Menu forum section is available at:

http://www.telerik.com/forums/kendo-ui/menu

Documentation article for dynamic items at:

http://docs.telerik.com/kendo-ui/controls/navigation/menu/overview#configuration-Dynamic

Additionally, check step 4 from the Kendo UI Menu model binding for ASP.NET MVC at:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/menu/overview#model-binding

as well as the Kendo UI Menu fluent MenuBuilder API reference at:

http://docs.telerik.com/kendo-ui/api/aspnet-mvc/Kendo.Mvc.UI.Fluent/MenuBuilder#methods-BindTo(System.Collections.IEnumerable,System.Action<Kendo.Mvc.UI.Fluent.NavigationBindingFactory<Kendo.Mvc.UI.MenuItem>>)

Let me know if you need further help with the Kendo UI Menu API.

Regards,
Alex
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
0
aaaaaaaaaa
Top achievements
Rank 1
answered on 31 Aug 2016, 12:47 PM
Hi
None of that examples apply for a dynamically created Menu.

I have the complete structure of a Menu in a table like:

Supply Chain
Vendors
Products
Contracts
Warehousing
Inventory
Transfers
Sanitation

In your examples you are hardcoding “category” and “products”, so how can I create the Menu without hardcoding?

Regards
Wilfredo
0
Alex Hajigeorgieva
Telerik team
answered on 02 Sep 2016, 03:07 PM
Hello Wilfredo,

I am sorry that you did not find the provided examples helpful. They demonstrate how to bind the Kendo UI Menu items to a model which can display various items as returned by the respective controller. Since they can be dynamically populated based on the server response, I would not refer to them as hardcoded. Perhaps I am missing something here, so could you please provide a sample project to show me what is the behaviour you would like to achieve.

If you prefer not to post your project here, you may open a new support ticket.

Look forward to hearing back from you. 

Regards,
Alex
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Visala
Top achievements
Rank 1
answered on 06 Nov 2017, 10:19 PM
Do you have an answer to this question.  I am also searching for the solution without hardcoding category and products?
0
Nencho
Telerik team
answered on 09 Nov 2017, 03:51 PM
Hello Visala,

The referenced binding approach with category and products is considered as dynamic, because you only specify which are the fields that the Menu should use as data source, while you can any dynamic data in there.

As an alternative, I would suggest you to bind the Menu directly to the model:

        @(Html.Kendo().Menu()
               .Name("Menu")
               .BindTo(Model)
         )
 
======================
        public ActionResult Index()
        {
            ViewBag.Message = "Welcome to ASP.NET MVC!";
 
            List<MenuItem> items = new List<MenuItem>();
 
            MenuItem item = new MenuItem();
            item.Text = "Item 1";
            item.Items.Add(new MenuItem { Text = "Sub Item 1.1"});
            item.Items.Add(new MenuItem { Text = "Sub Item 1.2" });
 
            MenuItem item1 = new MenuItem();
            item1.Text = "Item 2";
            item1.Items.Add(new MenuItem { Text = "Sub Item 2.1" });
            item1.Items.Add(new MenuItem { Text = "Sub Item 2.2" });
 
            items.Add(item);
            items.Add(item1);
 
            return View(items);
        }

In such a manner, you can build the needed data source at server-side and pass it through the model.

Regards,
Nencho
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Menu
Asked by
Parikshit
Top achievements
Rank 1
Answers by
aaaaaaaaaa
Top achievements
Rank 1
Alex Hajigeorgieva
Telerik team
Visala
Top achievements
Rank 1
Nencho
Telerik team
Share this question
or