| 
1 | 1 | ---  | 
2 | 2 | title: Items  | 
3 | 3 | page_title: jQuery Menu Documentation - Items  | 
4 |  | -description: "Get started with the jQuery Menu by Kendo UI and configure the items of the widget."  | 
 | 4 | +description: "Get started with the jQuery Menu by Kendo UI and configure the items of the component."  | 
5 | 5 | slug: items_kendoui_menu  | 
6 | 6 | position: 4  | 
7 | 7 | ---  | 
8 | 8 | 
 
  | 
9 | 9 | # Items  | 
10 | 10 | 
 
  | 
11 |  | -The Menu provides options for dynamically adding and removing its items.  | 
 | 11 | +The Menu component displays a hierarchical list of items, which can include submenus, icons, and custom templates. You can define the Menu items declaratively in the HTML or dynamically through JavaScript configuration.   | 
12 | 12 | 
 
  | 
13 |  | -To add items, provide the new item as a JSON object along with a reference item. A reference item is a target Menu item HTML element that already exists in the Menu. The reference item will be used to determine the placement in the hierarchy of the new item. Any valid jQuery selector can be used to obtain a reference to the target item. For more information, refer to the [demo on using the API of the Menu](https://demos.telerik.com/kendo-ui/menu/api).  | 
 | 13 | +You can configure the Menu items by specifying an array of objects, where each object represents a menu item. Each item can have the following properties:  | 
14 | 14 | 
 
  | 
15 |  | -The following example demonstrates how to add a new root Menu item.  | 
 | 15 | +| Name         | Type      | Description                                                                 |  | 
 | 16 | +|--------------|-----------|-----------------------------------------------------------------------------|  | 
 | 17 | +| `text`       | String    | The text displayed for the item.                                            |  | 
 | 18 | +| `url`        | String    | The URL to navigate to when the item is clicked.                            |  | 
 | 19 | +| `icon`       | String    | The name of a <a href="https://www.telerik.com/design-system/docs/foundation/iconography/icon-list/ target="_blank">built-in Kendo UI icon</a> to display.                            |  | 
 | 20 | +| `imageUrl`   | String    | The URL of an image to display as an icon.                                  |  | 
 | 21 | +| `items`      | Array     | An array of child items (submenus).                                         |  | 
 | 22 | +| `enabled`    | Boolean   | If set to `false`, the item will be disabled.                               |  | 
 | 23 | +| `cssClass`   | String    | A custom CSS class to apply to the item.                                    |   | 
16 | 24 | 
 
  | 
 | 25 | +## Setting the Text  | 
 | 26 | + | 
 | 27 | +You can define the text of the item using the `text` field.  | 
 | 28 | + | 
 | 29 | +```dojo  | 
 | 30 | +<ul id="menu"></ul>  | 
 | 31 | +
  | 
 | 32 | +<script>  | 
 | 33 | +    $("#menu").kendoMenu({  | 
 | 34 | +        dataSource: [  | 
 | 35 | +            { text: "File", items: [  | 
 | 36 | +                { text: "New"  },  | 
 | 37 | +                { text: "Open" },  | 
 | 38 | +                { text: "Save" }  | 
 | 39 | +            ]  | 
 | 40 | +            },  | 
 | 41 | +            { text: "Edit", items: [  | 
 | 42 | +                { text: "Cut" },  | 
 | 43 | +                { text: "Copy" },  | 
 | 44 | +                { text: "Paste" }  | 
 | 45 | +            ]  | 
 | 46 | +            },  | 
 | 47 | +            { text: "Help" }  | 
 | 48 | +        ]  | 
 | 49 | +    });  | 
 | 50 | +</script>  | 
 | 51 | +```  | 
 | 52 | + | 
 | 53 | +## Configuring URLs  | 
 | 54 | + | 
 | 55 | +You can set the URL of the items by using the `url` field. The URL will be rendered as an href attribute on the item link.  | 
 | 56 | + | 
 | 57 | +```dojo  | 
 | 58 | +    <ul id="menu"></ul>  | 
 | 59 | +    <script>  | 
 | 60 | +        $("#menu").kendoMenu({  | 
 | 61 | +            dataSource: [  | 
 | 62 | +                { text: "Home", url: "https://www.example.com/?item=1.1" },  | 
 | 63 | +                { text: "About Us", url: "https://www.example.com/?item=1.2" },   | 
 | 64 | +                { text: "Contact", url: "https://www.example.com/?item=1.3" }  | 
 | 65 | +            ]  | 
 | 66 | +        });  | 
 | 67 | +    </script>  | 
 | 68 | +```  | 
 | 69 | + | 
 | 70 | +## Showing Icons and Images  | 
 | 71 | + | 
 | 72 | +You can easily enhance the content in the Menu by showing an icon or an image through the `icon` and `imageUrl` fields:   | 
 | 73 | + | 
 | 74 | +```dojo  | 
17 | 75 |     <ul id="menu"></ul>  | 
 | 76 | +    <script>  | 
 | 77 | +      $("#menu").kendoMenu({  | 
 | 78 | +        dataSource: {  | 
 | 79 | +          data: [  | 
 | 80 | +            {  | 
 | 81 | +              Name: "Image Item",  | 
 | 82 | +              imgUrl: "https://demos.telerik.com/kendo-ui/content/shared/icons/sports/golf.png",  | 
 | 83 | +            },  | 
 | 84 | +            {  | 
 | 85 | +              Name: "Icon Item",  | 
 | 86 | +              icon: "gear",  | 
 | 87 | +            },  | 
 | 88 | +          ],  | 
 | 89 | +        },  | 
 | 90 | +        dataTextField: "Name",  | 
 | 91 | +        dataImageUrlField: "imgUrl",  | 
 | 92 | +      });  | 
 | 93 | +    </script>  | 
 | 94 | +```  | 
 | 95 | + | 
 | 96 | +## Adding Styles and Classes  | 
 | 97 | + | 
 | 98 | +You can add custom CSS classes to the Menu items through the `cssClass` field.  | 
 | 99 | + | 
 | 100 | +```dojo  | 
 | 101 | +    <ul id="menu"></ul>  | 
 | 102 | +    <script>  | 
 | 103 | +      $("#menu").kendoMenu({  | 
 | 104 | +        dataSource: [  | 
 | 105 | +          {  | 
 | 106 | +            text: "Red Item",  | 
 | 107 | +            cssClass: "red",  | 
 | 108 | +            items: [  | 
 | 109 | +              {text: "Sub Red Item" , cssClass: "red"}  | 
 | 110 | +            ]  | 
 | 111 | +          },  | 
 | 112 | +          {  | 
 | 113 | +            text: "Green Item",  | 
 | 114 | +            cssClass: "green",  | 
 | 115 | +            items: [  | 
 | 116 | +              {text: "Sub Green Item" , cssClass: "green"}  | 
 | 117 | +            ]  | 
 | 118 | +          }  | 
 | 119 | +        ],  | 
 | 120 | +      });  | 
 | 121 | +    </script>  | 
 | 122 | +    <style>  | 
 | 123 | +      .red {  | 
 | 124 | +        color: red !important;  | 
 | 125 | +      }  | 
 | 126 | +
  | 
 | 127 | +      .green {  | 
 | 128 | +        color: green !important;  | 
 | 129 | +      }  | 
 | 130 | +    </style>  | 
 | 131 | +```  | 
18 | 132 | 
 
  | 
 | 133 | +## Disabling Items  | 
 | 134 | + | 
 | 135 | +You can specify a Menu item as disabled by using the `enabled` field.  | 
 | 136 | + | 
 | 137 | +```dojo  | 
 | 138 | +    <ul id="menu"></ul>  | 
19 | 139 |     <script>  | 
20 |  | -        var menu = $("#menu").kendoMenu().data("kendoMenu");  | 
21 |  | -        menu.insertAfter(  | 
22 |  | -            { text: "New Menu Item" },  | 
23 |  | -            menu.element.children("li:last")  | 
24 |  | -        );  | 
 | 140 | +      $("#menu").kendoMenu({  | 
 | 141 | +        dataSource: [  | 
 | 142 | +          {  | 
 | 143 | +            text: "Item 1",               | 
 | 144 | +          },  | 
 | 145 | +          {  | 
 | 146 | +            text: "Disabled Item",   | 
 | 147 | +            enabled:false  | 
 | 148 | +          }  | 
 | 149 | +        ],  | 
 | 150 | +      });  | 
25 | 151 |     </script>  | 
 | 152 | +```  | 
26 | 153 | 
 
  | 
27 | 154 | ## See Also  | 
28 | 155 | 
 
  | 
29 |  | -* [Basic Usage of the Menu (Demo)](https://demos.telerik.com/kendo-ui/menu/index)  | 
 | 156 | +* [Overview of the Menu (Demo)](https://demos.telerik.com/kendo-ui/menu/index)  | 
30 | 157 | * [Using the API of the Menu (Demo)](https://demos.telerik.com/kendo-ui/menu/api)  | 
31 | 158 | * [JavaScript API Reference of the Menu](/api/javascript/ui/menu)  | 
0 commit comments