ContextMenu.body.items
configurationSpecifies 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 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: "Advanced",
items: [
{
text: "Process",
command: "ProcessCommand"
}
]
}
]
}
});
</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: "Tools",
items: [
{
text: "Edit",
icon: "edit",
command: "EditCommand"
}
]
}
]
}
});
</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: [
{
text: "Actions",
items: [
{
name: "subAction1",
text: "Sub Action 1",
command: "SubCommand1"
}
]
}
]
}
});
</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: "More Options",
items: [
{
text: "Copy Value",
command: "CopyCommand"
}
]
}
]
}
});
</script>