Kendo

  • UI Framework
  • Mobile
  • Demos
  • Roadmap
  • What's New
  • Download

Skin

  • Framework
  • UI Widgets
  • Integration

    Configuration API Functions
    • Description
    • View Code
    • Configuration (9)
    • Methods (5)
    • Events (2)

    The Grid widget displays tabular data and offers rich support interacting with data, including paging, sorting, grouping, and selection. Grid is a powerful widget with many configuration options. It can be bound to local JSON data or to remote data using the Kendo DataSource component.

    Getting Started

    There are two primary ways to create a Kendo Grid:
    1. From an existing HTML table element, defining columns, rows, and data in HTML
    2. From an HTML div element, defining columns and rows with configuration, and binding to data

    Creating a Grid from existing HTML Table element

     <!-- Define the HTML table, with rows, columns, and data -->
     <table id="grid">
      <thead>
          <tr>
              <th data-field="title">Title<th>
              <th data-field="year">Year<th>
          </tr>
      </thead>
      <tbody>
          <tr>
              <td>Star Wars: A New Hope<td>
              <td>1977<td>
          </tr>
          <tr>
              <td>Star Wars: The Empire Strikes Back<td>
              <td>1980<td>
          </tr>
      </tbody>
     </table>

    Initialize the Kendo Grid

      $(document).ready(function(){
          $("#grid").kendoGrid();
      });

    Creating a Grid from existing HTML Div element

     <!-- Define the HTML div that will hold the Grid -->
     <div id="grid">
     </div>

    Initialize the Kendo Grid and configure columns & data binding

       $(document).ready(function(){
          $("#grid").kendoGrid({
              columns:[
                  {
                      field: "FirstName",
                      title: "First Name"
                  },
                  {
                      field: "LastName",
                      title: "Last Name"
              }],
              dataSource: {
                  data: [
                      {
                          FirstName: "Joe",
                          LastName: "Smith"
                      },
                      {
                          FirstName: "Jane",
                          LastName: "Smith"
                  }]
              }
          });
      });

    Configuring Grid Behavior

    Kendo Grid supports paging, sorting, grouping, and scrolling. Configuring any of these Grid behaviors is done using simple boolean configuration options. For example, the follow snippet shows how to enable all of these behaviors.

    Enabling Grid paging, sorting, grouping, and scrolling

       $(document).ready(function(){
          $("#grid").kendoGrid({
             groupable: true,
             scrollable: true,
             sortable: true,
             pageable: true
          });
      });
    By default, paging, grouping, and sorting are disabled. Scrolling is enabled by default.

    Performance with Virtual Scrolling

    When binding to large data sets or when using large page sizes, reducing active in-memory DOM objects is important for performance. Kendo Grid provides built-in UI virtualization for highly optimized binding to large data sets. Enabling UI virtualization is done via simple configuration.

    Enabling Grid UI virtualization

       $(document).ready(function(){
          $("#grid").kendoGrid({
             scrollable: {
                 virtual: true
             }
          });
      });
    No code
    autoBind: Boolean(default: false)
    Indicates whether the grid will call query on DataSource initially.
    columns: Array
    A collection of column objects or collection of strings that represents the name of the fields.
    field: String
    The field that will displayed in the column.
    template: String
    The template for column's cells.

    Example

    $(".k-grid").kendoGrid({
         dataSource: {
             data: createRandomData(50),
             pageSize: 10
         },
         columns: [
             {
                 field: "Name"
             },
             {
                 field: "BirthDate",
                 title: "Birth Date",
                 template: '#= kendo.toString(BirthDate,"dd MMMM yyyy") #'
            }
         ]
      });
    title: String
    The title that will displayed in the column header.
    width: String
    The width of the column.
    dataSource: kendo.data.DataSource|Object
    Instance of DataSource or Object with DataSource configuration.

    Example

    var sharedDataSource = new kendo.data.DataSource({
         data: [{title: "Star Wars: A New Hope", year: 1977}, {title: "Star Wars: The Empire Strikes Back", year: 1980}],
         pageSize: 1
    });
    $("#grid").kendoGrid({
         dataSource: sharedDataSource
     });
     //or
     $("#grid").kendoGrid({
         dataSource: {
             data: [{title: "Star Wars: A New Hope", year: 1977}, {title: "Star Wars: The Empire Strikes Back", year: 1980}],
             pageSize: 1
         }
     });
    groupable: Boolean(default: false)
    Indicates whether grouping is enabled/disabled.
    navigatable: Boolean(default: false)
    Indicates whether keyboard navigation is enabled/disabled.
    pageable: Boolean(default: false)
    Indicates whether paging is enabled/disabled.
    rowTemplate: Function
    Template to be used for rendering the rows in the grid.

    Example

    //template
     <script id="rowTemplate" type="text/x-kendo-tmpl">
         <tr>
             <td>
                 <img src="${ BoxArt.SmallUrl }" alt="${ Name }" />
             </td>
             <td>
                 ${ Name }
             </td>
             <td>
                 ${ AverageRating }
             </td>
         </tr>
     </script>
     //grid intialization
     <script>
         $("#grid").kendoGrid({
             dataSource: dataSource,
             rowTemplate: kendo.template($("#rowTemplate").html()),
             height: 200
         });
     </script>
    scrollable: Boolean|Object(default: true)
    Enable/disable grid scrolling. Possible values:
    true
    Enables grid vertical scrolling
    false
    Disables grid vertical scrolling
    { virtual: false }
    Enables grid vertical scrolling without data virtualization. Same as first option.
    { virtual: true }
    Enables grid vertical scrolling with data virtualization.

    Example

    $("#grid").kendoGrid({
         scrollable: {
             virtual: true //false
         }
     });
    selectable: String(default: undefined)
    Indicates whether selection is enabled/disabled. Possible values:
    "row"
    Single row selection.
    "cell"
    Single cell selection.
    "multiple, row"
    Multiple row selection.
    "multiple, cell"
    Multiple cell selection.
    • clearSelection ()
      Clears currently selected items.
    • collapseGroup (group)
      Collapses specified group.

      Example

      // collapses first group item
      grid.collapseGroup(grid.tbody.find(">tr.k-grouping-row:first"));

      Parameters

      group: Selector|DOMElement
      Target group item to collapse.
    • expandGroup (group)
      Expands specified group.

      Example

      // expands first group item
      grid.expandGroup(grid.tbody.find(">tr.k-grouping-row:first"));

      Parameters

      group: Selector|DOMElement
      Target group item to expand.
    • refresh ()
      Reloads the data and repaints the grid.

      Example

      var grid = $("#grid").data("kendoGrid");
      // refreshes the grid
      grid.refresh();
    • select (items)
      Selects the specified Grid rows/cells. If called without arguments - returns the selected rows/cells.

      Example

      // selects first grid item
      grid.select(grid.tbody.find(">tr:first"));

      Parameters

      items: Selector|Array
      Items to select.
    change
    Fires when the grid selection has changed.
    dataBound
    Fires when the grid has received data from the data source.
    • Home
    • UI Framework
    • Mobile
    • Demos
    • Roadmap
    • What's New
    • Blogs
    • Forums
    • Documentation
    • FAQ
    • About
    • Follow us on Twitter
    • Subscribe to our RSS feed

    Kendo UI is powered by Telerik

    Copyright © 2011 Telerik Inc. All rights reserved.