Edit this page

toolbar String |Function |Array

If a String value is assigned to the toolbar configuration option, it will be treated as a single string template for the whole grid Toolbar, and the string value will be passed as an argument to a kendo.template() function.

If a Function value is assigned (it may be a kendo.template() function call or a generic function reference), then the return value of the function will be used to render the Grid Toolbar contents.

If the grid is instantiated with MVVM, The template passed will not be bound to the grid view model context. You may bind the toolbar element manually afterwards, using kendo.bind(gridWidgetInstance.element.find("k-grid-toolbar"))

If an Array value is assigned, it will be treated as the list of commands displayed in the grid's Toolbar. Commands can be custom or built-in ("cancel", "create", "save", "excel", "pdf").

The "cancel" built-in command reverts any data changes done by the end user.

The "create" command adds an empty data item to the grid.

The "save" command persists any data changes done by the end user.

The "excel" command exports the grid data in MS Excel format.

The "pdf" command exports the grid data in PDF format.

Example - configure the Grid Toolbar as a string template

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  toolbar: "<p>My string template in a paragraph.</p>",
  columns: [
    { field: "name" },
    { field: "age" }
  ],
  dataSource: {
    data: [
      { id: 1, name: "Jane Doe", age: 30 },
      { id: 2, name: "John Doe", age: 33},
    ],
    schema: {
      model: { id: "id" }
    }
  },
  editable: true
});
</script>

Example - configure the Grid Toolbar template with a function

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  toolbar: kendo.template("<p>My function template.</p>"),
  columns: [
    { field: "name" },
    { field: "age" }
  ],
  dataSource: {
    data: [
      { id: 1, name: "Jane Doe", age: 30 },
      { id: 2, name: "John Doe", age: 33},
    ],
    schema: {
      model: { id: "id" }
    }
  },
  editable: true
});
</script>

Example - configure the Grid Toolbar as an array of commands

<div id="grid"></div>
<script>
$("#grid").kendoGrid({
  toolbar: [
    { name: "create" },
    { name: "save" },
    { name: "cancel" }
  ],
  columns: [
    { field: "name" },
    { field: "age" }
  ],
  dataSource: {
    data: [
      { id: 1, name: "Jane Doe", age: 30 },
      { id: 2, name: "John Doe", age: 33},
    ],
    schema: {
      model: { id: "id" }
    }
  },
  editable: true
});
</script>