Book Image

Instant Kendo UI Grid

By : James R. Lamar
Book Image

Instant Kendo UI Grid

By: James R. Lamar

Overview of this book

<p>Kendo grids are the perfect fit if you need a powerful set of tools to let users manipulate data, or even if you just want a great way to dress up existing tables.</p> <p>Instant Kendo UI Grid is a practical, hands-on guide that will provide dozens of working examples and also serve as a reference for customizing your grids in no time. It will teach you to create detailed and beautiful grids. This book takes you through the many options and variations of using Kendo UI grids. The readers will end up being comfortable implementing grids in any relevant situation.</p> <p>You will learn about how to develop elaborate grids to handle any CRUD (Create, Read, Update, Delete) operation in a way that is easily maintained and even easier to develop. Styling is a breeze with Kendo UI themes, which also happens to include a theme to match the ever popular Twitter Bootstrap.</p> <p>Instant Kendo UI Grid is your go-to reference for creating amazingly beautiful and highly functional grids for tabular data.</p>
Table of Contents (7 chapters)

Using built-in paging (Simple)


This recipe demonstrates the built-in paging feature of Kendo Grids.

Getting ready

Open 3-paging.html in your editor or create a new HTML file with the same name.

How to do it...

Copy the following code into your new document:

<!DOCTYPE html>
<html>
<head>
<title>Kendo UI Grid How-to</title>
<link rel="stylesheet" type="text/css" href="kendo/styles/kendo.common.min.css">
<link rel="stylesheet" type="text/css" href="kendo/styles/kendo.default.min.css">
<script src="kendo/js/jquery.min.js"></script>
<script src="kendo/js/kendo.web.min.js"></script>
</head>
<body>
<h3 style="color:#4f90ea;">Exercise 3 - Using Built-in Paging</h3>
<p><a href="index.html">Home</a></p>
<script type="text/javascript">
  $(document).ready(function(){
     $("#myGrid").kendoGrid({
      pageable: {
         pageSize: 2,
         previousNext: true, // default true
         numeric: true, // default true
         buttonCount: 2, // default 10, controls how many buttons are shown which represent pages of data
         refresh: true, // default false
         input: true, // default false
         messages: {
            display: "{0} - {1} of {2} records",
            empty: "Nothing to display",
            page: "Page",
            of: "of {0}",
            itemsPerPage: "records per page",
            first: "Go to the first page",
            previous: "Go to the previous page",
            next: "Go to the next page",
            last: "Go to the last page",
            refresh: "Refresh"
         }
      }
     });
  });
</script>
<table id="myGrid">
   <thead>
      <tr>
         <th>First Name</th>
         <th>Last Name</th>
         <th>Rank</th>
      </tr>
   </thead>
   <tbody>
      <tr>
         <td>Jim</td>
         <td>Kirk</td>
         <td>Captain</td>
      </tr>
   <tr>
         <td>Jim</td>
         <td>Raynor</td>
         <td>Captain</td>
      </tr>
      <tr>
         <td>Sarah</td>
         <td>Kerrigan</td>
         <td>Ghost Recon</td>
      </tr>
      <tr>
         <td>Jean-Luc</td>
         <td>Picard</td>
         <td>Captain</td>
      </tr>
      <tr>
         <td>Steve</td>
         <td>Rogers</td>
         <td>Captain</td>
      </tr>
   </tbody>
</table>
</body>
</html>

How it works...

Like with the sorting feature, you can simply give the pageable parameter a value of true, but this code shows several examples of refining the paging feature of the grid.