Kendo UI Vertical and Horizontal Menu

Menu

A menu is a list of commands or choices offered to the user. Menus commonly allow a user to access the various options the software program is capable of performing. The vertical menu displays the menu one by one. The horizontal menu is used to display the menu in a single row.

Kendo UI Menu

The Kendo UI menu represents the Kendo UI menu widget. The Menu displays hierarchical data as a multi-level menu. It can be defined and initialized from HTML, or the API can be used to add and remove items. The Kendo UI menu is shown in one of the following three ways.

  1. Configuration
  2. Methods
  3. Events

 

 

Configuration

  • Animation Object: The animation objects are used to change default animations. A value of false will disable all animations in the widget.
  • Animation.close Object: The animation.close object that will be used when closing sub menus.
  • Animation.close.effects: This effect is used to closing the popup string.
  • Animation.close.duration: It is used to define the animation duration of seconds.
  • Animation.open Object: The animation that is used when opening sub menus.
  • Animation.open.effects String: Effect to be used for opening of the popup.
  • Animation.open.duration Number: Defines the animation duration in milliseconds.
  • CloseOnClick Boolean: Specifies that sub menus should close after item selection. The closeOnClick Boolean is set as the default of true.
  • DataSource Object|Array: The data source of the widget is used to render its items. It contains an item or an Array of items to be rendered.
  • Direction String(default: "default"): Specifies the menu opening direction. Can be "top", "bottom", "left", "right". The user also can specify a different direction for root and sub menu items separating them with a space.
  • HoverDelay Number(default: 100): The delay prior to the menu being opened/closed, to avoid accidental closure on leaving.
  • OpenOnClick Boolean(default: false): The root sub menus will be opened on item click.
  • Orientation String(default: "horizontal"): Root menu orientation could be horizontal or vertical.
Methods
 
  • Append: Appends menu is specified reference sub-menu.
  • Close: Closes a sub-menu of a specified item in a menu.
  • Destroy: All event handlers and removes jQuery data attributes to avoid memory leaks. Calls destroy method of any child Kendo widgets.
  • Enable: Enables or disables an item of a menu.
  • InsertAfter: Inserts an item into a menu after the specified reference item.
  • InsertBefore: Inserts an item into a menu before the specified reference item.
  • Open: Opens a sub-menu of a specified item in a menu.
  • Remove: Removes a specified item from a menu. 
Events

 

  • Close: Before a sub menu is closed. The user cancels this event to prevent closure.
  • Open: Before a sub menu is opened. The user cancels this event to prevent opening the sub menu.
  • Activate: When a sub menu is opened and its animation is finished.
  • Deactivate: When a sub menu is closed and its animation is finished.
  • Select: when a menu item is selected. 
Now for how to use the Kendo UI vertical and horizontal menu in ASP.NET. First create a simple web application and add a HTML page and JavaScript page. Install the Kendo UI then start writing the code. You want to learn how to create a simple web application in ASP.NET, refer to my previous article Using Kendo UI Templates.

First you design the HTML page using the following code:

  1. <!DOCTYPE html>  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4.     <title>Welcome kendo Menu</title>  
  5.     <link href="Content/kendo/2014.1.318/kendo.default.min.css" rel="stylesheet" />  
  6.     <link href="Content/kendo/2014.1.318/kendo.common.min.css" rel="stylesheet" />  
  7.     <script src="Scripts/kendo/2014.1.318/jquery.min.js"></script>  
  8.     <script src="Scripts/kendo/2014.1.318/kendo.web.min.js"></script>  
  9.     <script src="Scripts/JavaScript1.js"></script>  
  10. </head>  
  11. <body>  
  12.     <div id="menu"></div>  
  13. </body>  
  14. </html>   
Now you design the JavaScript page using the following code:
  1. /// <reference path="kendo/2014.1.318/jquery.min.js" />  
  2. /// <reference path="kendo/2014.1.318/kendo.web.min.js" />  
  3.    
  4. $(document).ready(function () {  
  5.     $("#menu").kendoMenu({  
  6.         dataSource: [  
  7.             {  
  8.                 text: "ASP.NET MVC Versions",  
  9.                 value: "Item 1 Value",  
  10.                 items: [  
  11.                     {  
  12.                         text: " MVC 1",  
  13.                         value: "Sub Item 1 Value",  
  14.                         items: [  
  15.                             {  
  16.                                 text: "MVC Pattern architecture with WebForm Engine, Runs on .Net 3.5 and with Visual Studio 2008 & Visual Studio 2008 SP1, Html and Ajax helpers, Routing, Unit Testing.",  
  17.                                 value: "Sub Sub Item 1 Value"  
  18.                             },  
  19.                         ]  
  20.                     },  
  21.                     {  
  22.                         text: " MVC 2",  
  23.                         value: "Sub Item 2 Value",  
  24.                         items: [  
  25.                             {  
  26.                                 text: "Strongly typed HTML helpers means lambda expression based Html Helpers, Templated and UI helpers with automatic scaffolding & customizable templates, Client-side validation, Asynchronous controllers.",  
  27.                                 value: "Sub Sub Item 2 Value"  
  28.                             },  
  29.                         ]  
  30.                     },  
  31.                     {  
  32.                         text: " MVC 3",  
  33.                         value: "Sub Item 3 Value",  
  34.                         items: [  
  35.                             {  
  36.                                 text: "Improved Support for Data Annotations, Remote Validation, Dependency Resolver, Entity Framework Code First support, Good Intellisense support for Razor into Visual Studio, Use of NuGet to deliver software and manage dependencies throughout the platform.",  
  37.                                 value: "Sub Sub Item 3 Value"  
  38.                             },  
  39.                         ]  
  40.                     },  
  41.                     {  
  42.                         text: " MVC 4",  
  43.                         value: "Sub Item 4 Value",  
  44.                         items: [  
  45.                             {  
  46.                                 text: "ASP.NET Web API, Runs on .Net 4.0, 4.5 and with Visual Studio 2010SP1 & Visual Studio 2012, Display Modes, Enhancements to default project templates, Mobile project template using jQuery Mobile, Support for the Windows Azure SDK.",  
  47.                                 value: "Sub Sub Item 4 Value"  
  48.                             },  
  49.                         ]  
  50.                     },  
  51.                     {  
  52.                         text: " MVC 5",  
  53.                         value: "Sub Item 5 Value",  
  54.                         items: [  
  55.                             {  
  56.                                 text: "Runs on .Net 4.5, 4.5.1 and with Visual Studio 2013, Asp.Net Identity and Scaffolding, Bootstrap in the MVC template, ASP.NET Web API2, Authentication filters - run prior to authorization filters in the ASP.NET MVC pipeline.",  
  57.                                 value: "Sub Sub Item 5 Value"  
  58.                             },  
  59.                         ]  
  60.                     },  
  61.                 ]  
  62.             },  
  63.         {  
  64.             text: ".NET Framework Versions",  
  65.             value: "Item 1 Value",  
  66.             items: [  
  67.                 {  
  68.                     text: ".NET Framework 1.0",  
  69.                     value: "Sub Item 1 Value",  
  70.                     items: [  
  71.                         {  
  72.                             text: "This is the First version of the .NET Framework.",  
  73.                             value: "Sub Sub Item 1 Value"  
  74.                         },  
  75.                     ]  
  76.                 },  
  77.                 {  
  78.                     text: ".NET Framework 1.1",  
  79.                     value: "Sub Item 2 Value",  
  80.                     items: [  
  81.                         {  
  82.                             text: "ASP.NET and ADO.NET updates, Side-by-side execution.",  
  83.                             value: "Sub Sub Item 2 Value"  
  84.                         },  
  85.                     ]  
  86.                 },  
  87.                 {  
  88.                     text: ".NET Framework 2.0",  
  89.                     value: "Sub Item 3 Value",  
  90.                     items: [  
  91.                         {  
  92.                             text: "ASP.NET and ADO.NET updates, Access Control List Support. 64-Bit Platform Support, Authenticated Streams, COM Interop Services Enhancements.",  
  93.                             value: "Sub Sub Item 3 Value"  
  94.                         },  
  95.                     ]  
  96.                 },  
  97.                 {  
  98.                     text: ".NET Framework 3.0",  
  99.                     value: "Sub Item 4 Value",  
  100.                     items: [  
  101.                         {  
  102.                             text: "This 3.0 version support to WPF, WCF, WF, CardSpace.",  
  103.                             value: "Sub Sub Item 4 Value"  
  104.                         },  
  105.                     ]  
  106.                 },  
  107.                 {  
  108.                     text: " .NET Framework 3.5",  
  109.                     value: "Sub Item 5 Value",  
  110.                     items: [  
  111.                         {  
  112.                             text: "AJAX-enabled websites, LINQ, Dynamic data, Cryptography.",  
  113.                             value: "Sub Sub Item 5 Value"  
  114.                         },  
  115.                     ]  
  116.                 },  
  117.                 {  
  118.                     text: ".NET Framework 4",  
  119.                     value: "Sub Item 2 Value",  
  120.                     items: [  
  121.                         {  
  122.                             text: "Expanded base class libraries, Cross-platform development with Portable Class Library, MEF, DLR, code contracts.",  
  123.                             value: "Sub Sub Item 2 Value"  
  124.                         },  
  125.                     ]  
  126.                 },  
  127.                 {  
  128.                     text: ".NET Framework 4.5",  
  129.                     value: "Sub Item 3 Value",  
  130.                     items: [  
  131.                         {  
  132.                             text: "WPF, WCF, WF, ASP.NET updates, Support for Windows Store apps, Type reflection support split between Type and TypeInfo classes.",  
  133.                             value: "Sub Sub Item 3 Value"  
  134.                         },  
  135.                     ]  
  136.                 },  
  137.                 {  
  138.                     text: ".NET Framework 4.5.1",  
  139.                     value: "Sub Item 4 Value",  
  140.                     items: [  
  141.                         {  
  142.                             text: ".NET Native, Support for Windows Phone Store apps, Automatic binding redirection, Performance and debugging improvements.",  
  143.                             value: "Sub Sub Item 4 Value"  
  144.                         },  
  145.                     ]  
  146.                 },  
  147.                 {  
  148.                     text: ".NET Framework 4.5.2",  
  149.                     value: "Sub Item 5 Value",  
  150.                     items: [  
  151.                         {  
  152.                             text: "New APIs for transactional systems and ASP.NET, System DPI resizing in Windows Forms controls, Profiling improvements, ETW and stress logging improvements.",  
  153.                             value: "Sub Sub Item 5 Value"  
  154.                         },  
  155.                     ]  
  156.                 },  
  157.             ]  
  158.         }]  
  159.     });  
  160. });  
The code above uses the Kendo UI menu to display the output in a horizontal and vertical order. Now see the output in the following. The following output window displays only a horizontal menu.
 
 
 
The following output window displays a horizontal and vertical menu.
 
 
 
This final output window displays all the vertical and horizontal menus and includes a sub menu also. The following output window ASP.NET MVC versions and .NET Framework Versions is a horizontal menu, MVC 1 up to MVC 5 is a vertical menu. 
 
 
 
The following window .NET Framework 1.0, 1.1 and up to 4.5.2 is a sub menu of .NET Framework Versions and ASP.NET and ADO.NET updates is a sub menu of .NET Framework 1.1.
 
 
 
Summary
 
This article described the use of the Kendo UI vertical and horizontal sub menu in web applications of ASP.NET. This article helps you to learn the Kendo UI Menu and the example program helpd to learn ASP.NET MVC versions and to learn the .NET Framework versions and features. Thanks for reading the article.


Similar Articles