New to Kendo UI for jQueryStart a free 30-day trial

ContextMenu.head

configuration

Configures the items of the ContextMenu for the table head element. Those are some valid predifined tools: "separator", "create", "edit", "destroy", "select", "copySelection",."copySelectionNoHeaders", "reorderRow", "exportPDF", "exportExcel", "sortAsc", "sortDesc".

You can also specify a custom item and accosiate it with a command.

<div id="grid"></div>
<script>
    $("#grid").kendoGrid({
        contextMenu: {
            head: [
                "sortAsc",
                "sortDesc",
                "exportExcel",
                { name: "MyCustomCommand", text: "My Custom Command", icon: "gear", command: "CustomCommand" }
            ]
            // You can also concat to the default tools
            // head: kendo.ui.grid.defaultHeadContextMenu.concat([
            //     { name: "MyCustomCommand", text: "My Custom Command", icon: "gear", command: "CustomCommand" }
            // ])
        },
        editable: true,
        sortable: true,
        draggable: true,
        reorderable: true,
        dataSource: new kendo.data.DataSource({
            schema: {
                model: {
                    id: "foo",
                    fields: {
                        name: "name",
                        foo: "foo",
                    },
                },
            },
            data: [
                { foo: "bar", name: "tom" },
                { foo: "baz", name: "jerry" },
            ],
        }),
    });

    kendo.ui.grid.commands["CustomCommand"] = kendo.ui.grid.GridCommand.extend({
        exec: function() {
            var that = this,
                grid = that.grid;

            grid.saveAsPDF();
        }
    });
</script>

Specifies the command of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" },
    { field: "unitPrice" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages", unitPrice: 2.5 },
    { productName: "Coffee", category: "Beverages", unitPrice: 3.0 }
  ],
  editable: "inline",
  contextMenu: {
    head: [
      {
        name: "editrow",
        text: "Edit Row",
        command: "edit"
      }
    ]
  }
});
</script>

Specifies the icon of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" },
    { field: "unitPrice" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages", unitPrice: 2.5 },
    { productName: "Coffee", category: "Beverages", unitPrice: 3.0 }
  ],
  contextMenu: {
    head: [
      {
        name: "editrow",
        text: "Edit Row",
        icon: "k-icon k-i-edit"
      }
    ]
  }
});
</script>

Specifies the items of the item.

<div id="grid"></div>
<script>
    $("#grid").kendoGrid({
        contextMenu: {
            head: [
                {
                    text: "Custom Command",
                    icon: "calendar",
                    items: [
                        { text: "Nested Custom Command", icon: "home", command: "NestedCustomCommand" }
                    ]
                },
                'select'
            ]
        },
        dataSource: new kendo.data.DataSource({
            schema: {
                model: {
                    id: "foo",
                    fields: {
                        name: "name",
                        foo: "foo",
                    },
                },
            },
            data: [
                { foo: "bar", name: "tom" },
                { foo: "baz", name: "jerry" },
            ],
        }),
    });

    kendo.ui.grid.commands["NestedCustomCommand"] = kendo.ui.grid.GridCommand.extend({
        exec: function(e) {
             alert("Custom Command Executed")
        }
    });
</script>

Specifies the name of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" },
    { field: "unitPrice" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages", unitPrice: 2.5 },
    { productName: "Coffee", category: "Beverages", unitPrice: 3.0 }
  ],
  contextMenu: {
    head: [
      {
        name: "editrow",
        text: "Edit Row",
        icon: "edit"
      }
    ]
  }
});
</script>

Specifies the text of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" },
    { field: "unitPrice" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages", unitPrice: 2.5 },
    { productName: "Coffee", category: "Beverages", unitPrice: 3.0 }
  ],
  contextMenu: {
    head: [
      {
        name: "editrow",
        text: "Edit Current Row",
        icon: "edit"
      }
    ]
  }
});
</script>