Last month Telerik released a major update of the Kendo UI. In this article I share some important added features in the Kendo grid. Get recent Kendo UI bundles.
I am using two REST services provided by Telerik:
- http://worldcup.sfg.io/teams/results
- http://worldcup.sfg.io/matches/today
The first service end point will consist of some data and the second service end point will consist of empty data.
Figure 1 shows the first REST Service result in POSTMAN.
Figure 1Figure 2 shows the second REST Service result in POSTMAN.
Figure 2
The following are the added features in the Kendo Grid.
1. NoRecords option
The NoRecords option displays no record message if there is no data in the Kendo grid.
Let's have a demo of it.
Case 1: using http://worldcup.sfg.io/teams/results.
HTML design
- <!DOCTYPE html>
- <html
- xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <script src="js/jquery.min.js"></script>
- <script src="js/jszip.min.js"></script>
- <script src="js/kendo.all.min.js"></script>
- <script src="js/kendo.web.min.js"></script>
- <link href="styles/kendo.metro.min.css" rel="stylesheet" />
-
- link href="styles/kendo.common.min.css" rel="stylesheet" />
- <title></title>
- </head>
- <body>
- <h4>Kendo update</h4>
- <div id="example">
- <div id="grid"></div>
- </div>
- </body>
- </html>
JavaScript
- < script >
-
- $(document).ready(function() {
-
- $("#grid").kendoGrid({
-
- dataSource: {
-
- type: "jsonp",
-
- transport: {
-
- read: "http://worldcup.sfg.io/teams/results"
-
- },
-
- pageSize: 20
-
- },
-
- height: 550,
-
- groupable: true,
-
- sortable: true,
-
- pageable: {
-
- refresh: true,
-
- pageSizes: true,
-
- buttonCount: 5
-
- },
-
- columns: [{
-
- field: "country",
-
- title: "Country",
-
- width: 240
-
- }, {
-
- field: "fifa_code",
-
- title: "Fifa Code"
-
- }, ]
-
- });
-
- });
-
- < /script>
Figure 3 shows the result in a browser.
Figure 3
Case 2: using http://worldcup.sfg.io/matches/today Service
JavaScript
- < script >
-
- $(document).ready(function() {
-
- $("#grid").kendoGrid({
-
- dataSource: {
-
- type: "jsonp",
-
- transport: {
-
- read: "http://worldcup.sfg.io/matches/today"
-
- },
-
- pageSize: 20
-
- },
-
- height: 550,
-
- groupable: true,
-
- sortable: true,
-
- pageable: {
-
- refresh: true,
-
- pageSizes: true,
-
- buttonCount: 5
-
- },
-
- columns: [{
-
- field: "country",
-
- title: "Country",
-
- width: 240
-
- }, {
-
- field: "fifa_code",
-
- title: "Fifa Code"
-
- }, ]
-
- });
-
- });
-
- < /script>
Result in Browser
Figure 4 You can see one thing in Figure 4, that is that there is no record to display in the grid, it is the developer's responsibility to show a no record message to the user. Now Kendo gives a new feature called noRecords. It is one of the properties in the Kendo grid to display the no record message.
Case 3: using noRecords property.
JavaScript
- < script >
-
- $(document).ready(function() {
-
- $("#grid").kendoGrid({
-
- dataSource: {
-
- type: "jsonp",
-
- transport: {
-
- read: "http://worldcup.sfg.io/matches/today"
-
- },
-
- pageSize: 20
-
- },
-
- height: 550,
-
- groupable: true,
-
- sortable: true,
-
- noRecords: true,
-
- pageable: {
-
- refresh: true,
-
- pageSizes: true,
-
- buttonCount: 5
-
- },
-
- columns: [{
-
- field: "country",
-
- title: "Country",
-
- width: 240
-
- }, {
-
- field: "fifa_code",
-
- title: "Fifa Code"
-
- }, ]
-
- });
-
- });
-
- < /script>
Figure 5 shows the result in a browser.
Figure 5
2. Customizing the noRecord property
We can customize the default message that is displayed in the grid when there is no record using the message property.
Let's have a demo of it.
JavaScript
- < script >
-
- $(document).ready(function() {
-
- $("#grid").kendoGrid({
-
- dataSource: {
-
- type: "jsonp",
-
- transport: {
-
- read: "http://worldcup.sfg.io/matches/today"
-
- },
-
- pageSize: 20
-
- },
-
- height: 550,
-
- groupable: true,
-
- sortable: true,
-
- noRecords: true,
-
- messages: {
-
- noRecords: "Sorry , No Record Found!"
-
- },
-
- pageable: {
-
- refresh: true,
-
- pageSizes: true,
-
- buttonCount: 5
-
- },
-
- columns: [{
-
- field: "country",
-
- title: "Country",
-
- width: 240
-
- }, {
-
- field: "fifa_code",
-
- title: "Fifa Code"
-
- }, ]
-
- });
-
- });
-
- < /script>
Figure 6 shows the result in a browser.
Figure 6
3. Adding Templates in the noRecord property
We can more customize the noRecord property using templates.
Let's have a demo of that.
JavaScript
- < script >
-
- $(document).ready(function() {
-
- $("#grid").kendoGrid({
-
- dataSource: {
-
- type: "jsonp",
-
- transport: {
-
- read: "http://worldcup.sfg.io/matches/today"
-
- },
-
- pageSize: 20
-
- },
-
- height: 550,
-
- groupable: true,
-
- sortable: true,
-
- noRecords: {
-
- template: "<img src=/no-record-found.jpg> </img>"
-
- },
-
- pageable: {
-
- refresh: true,
-
- pageSizes: true,
-
- buttonCount: 5
-
- },
-
- columns: [{
-
- field: "country",
-
- title: "Country",
-
- width: 240
-
- }, {
-
- field: "fifa_code",
-
- title: "Fifa Code"
-
- }, ]
-
- });
-
- });
-
- < /script>
Figure 6 shows the result in a browser.
Figure 7
The
All options in the paging toolbar is one of the added features in Kendo Grid where the user can get all records in a single page.
Figure 8 shows five records in each page.
Figure 8
Figure 9 shows all records in a single page.
Figure 9
I hope you have enjoyed this article.
Thank you.