Book Image

Kendo UI Cookbook

By : Sagar Ganatra
Book Image

Kendo UI Cookbook

By: Sagar Ganatra

Overview of this book

Table of Contents (18 chapters)
Kendo UI Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sorting data in a Grid using a selected column


The Kendo UI Grid comes with several features, such as sorting by selected columns, pagination, grouping, and scrolling. These configuration options can be specified at the Grid configuration level and at the column level as well.

How to do it…

To enable the sort by column feature, set the sortable configuration option to true. This will make all the columns in the Grid available for sorting. If you want some of the columns in the Grid to not be available for sorting, then you can add the same property, sortable, with a false value at the column level as well:

$("#grid").kendoGrid({
  columns: [
    {
      field : 'movieName',
      title : 'Movie',
      sortable: false,
    },
    {
      field : 'year',
      title : 'Year' 
    },
    {
      field : 'rating',
      title : 'Rating'
    }
  ],  
  dataSource: {
    transport: {
      read: 'http://localhost/kendo/code/chapter2/remote.json'
    }
  },
  sortable: true
});

Here, by adding sortable...