Edit this page

append

Appends an item to a ContextMenu in the specified referenceItem's sub menu (or the root context menu if not specified).

Example

<div id="target">Target</div>
<ul id="context-menu"></ul>
<script>
    // initialize the ContextMenu
    $("#context-menu").kendoContextMenu({
        target: "#target"
    });

    // get a reference to already initialized ContextMenu widget
    var contextMenu = $("#context-menu").data("kendoContextMenu");

    contextMenu.append(
        [{
            text: "Item 1",
            cssClass: "myClass",                         // Add custom CSS class to the item, optional, added 2012 Q3 SP1.
            url: "http://www.telerik.com"                // Link URL if navigation is needed, optional.
        },
        {
            text: "<b>Item 2</b>",
            encoded: false,                              // Allows use of HTML for item text
            content: "text"                              // content within an item
        },
        {
            text: "Item 3",
            imageUrl: "http://www.telerik.com/test.jpg", // Item image URL, optional.
            items: [{                                    // Sub item collection
                 text: "Sub Item 1"
            },
            {
                 text: "Sub Item 2"
            }]
        },
        {
            text: "Item 4",
            spriteCssClass: "imageClass3"                // Item image sprite CSS class, optional.
        }]
    );
</script>

Parameters

item Object |Array

Item to be appended, specified as a JSON object. An array of objects can also be passed.

referenceItem String |jQuery (optional)

A reference item to append the new item in. If omitted, the new item will be appended to the as a root item.

Returns

kendo.ui.ContextMenu Returns the ContextMenu object to support chaining.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy