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

ContextMenu.body

configuration

Configures the items of the ContextMenu for the table body 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: {
            body: [
                "exportPDF",
                "exportExcel",
                { name: "MyCustomCommand", text: "My Custom Command", icon: "gear", command: "CustomCommand" }
            ]
            // You can also concat to the default tools
            // body: kendo.ui.grid.defaultBodyContextMenu.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" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages" },
    { productName: "Coffee", category: "Beverages" }
  ],
  contextMenu: {
    body: [
      {
        text: "Export Row",
        command: "ExportRowCommand"
      }
    ]
  }
});
</script>

Specifies the icon of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages" },
    { productName: "Coffee", category: "Beverages" }
  ],
  contextMenu: {
    body: [
      {
        text: "Settings",
        icon: "gear",
        command: "SettingsCommand"
      }
    ]
  }
});
</script>

Specifies the items of the item.

<div id="grid"></div>
<script>
    $("#grid").kendoGrid({
        contextMenu: {
            body: [
                {
                    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" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages" },
    { productName: "Coffee", category: "Beverages" }
  ],
  contextMenu: {
    body: [
      {
        name: "customAction",
        text: "Custom Action",
        command: "CustomCommand"
      }
    ]
  }
});
</script>

Specifies the text of the item.

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  columns: [
    { field: "productName" },
    { field: "category" }
  ],
  dataSource: [
    { productName: "Tea", category: "Beverages" },
    { productName: "Coffee", category: "Beverages" }
  ],
  contextMenu: {
    body: [
      {
        text: "Analyze Row",
        command: "AnalyzeCommand"
      }
    ]
  }
});
</script>