How to Create Dynamic Menu In MVC Razor Application

7 posts, 0 answers
  1. Parikshit
    Parikshit avatar
    1 posts
    Member since:
    Jan 2012

    Posted 30 Jan 2012 Link to this post


    How To Create Dynamic Menu using Kendo ui in MVC Razor Application..........
  2. aaaaaaaaaa
    aaaaaaaaaa avatar
    2 posts
    Member since:
    May 2016

    Posted 26 Aug 2016 Link to this post

    Five years ago and Telerik doesn't have an answer?
  3. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    442 posts

    Posted 31 Aug 2016 Link to this post

    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.
  4. aaaaaaaaaa
    aaaaaaaaaa avatar
    2 posts
    Member since:
    May 2016

    Posted 31 Aug 2016 in reply to Alex Hajigeorgieva Link to this post

    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
  5. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    442 posts

    Posted 02 Sep 2016 Link to this post

    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
  6. Visala
    Visala avatar
    1 posts
    Member since:
    Oct 2017

    Posted 06 Nov 2017 in reply to Alex Hajigeorgieva Link to this post

    Do you have an answer to this question.  I am also searching for the solution without hardcoding category and products?
  7. Nencho
    Admin
    Nencho avatar
    1745 posts

    Posted 09 Nov 2017 Link to this post

    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.
Back to Top