Hi,
I am rebinding datasource to Grid on click event of button but paging doesn't work properly.
My code is like this.
I am rebinding datasource to Grid on click event of button but paging doesn't work properly.
My code is like this.
<!DOCTYPE html> <html> <head> <title>YouTube</title> <link href="Kendo/kendo.common.css" rel="stylesheet" type="text/css" /> <link href="Kendo/kendo.default.css" rel="stylesheet" type="text/css" /> <script src="Kendo/jquery-1.8.2.js" type="text/javascript"></script> <script src="Kendo/kendo.web.js" type="text/javascript"></script> <script src="Kendo/console.js" type="text/javascript"></script> <style scoped type="text/css"> #clientsDb { width: 692px; height: 413px; margin: 30px auto; padding: 51px 4px 0 4px; } </style> </head> <body> <input id="txtSearch" type="text" /> <input id="btnView" type="button" value="view" onclick="GetVideos(); return false;" /> <div id="example" class="k-content"> <div id="clientsDb"> <div> </div> <table id="grid" style="height: 380px;"> <thead> <tr> <th colspan="3"> Videos </th> </tr> </thead> <tbody> <tr> <td colspan="3"> </td> </tr> </tbody> </table> </div> <script id="rowTemplate" type="text/x-kendo-tmpl"> <tr class="k-alt"> <td colspan="3"> <img src="${ media$group.media$thumbnail[1].url }" alt="${ title.$t }" /> <span> <a onclick="" href="${link[0].href}">Play</a> </span> <br /> ${ title.$t } </td> </tr> </script> <script type="text/javascript"> function GetVideos() { var grid = $("#grid").data("kendoGrid"); var template = kendo.template($("#rowTemplate").html()); var dataSource = new kendo.data.DataSource({ transport: { read: { // the remote service url url: "https://gdata.youtube.com/feeds/api/videos?alt=json&q=" + $("#txtSearch").val() + "&orderby=relevance", // JSONP is required for cross-domain AJAX dataType: "jsonp" } }, schema: { data: "feed.entry" }, change: function () { // subscribe to the CHANGE event of the data source $("#grid tbody").html(kendo.render(template, this.view())); // populate the table } , pageSize: 5, pageable: true, serverPaging: true }); dataSource.read(); grid.refresh(); return false; } $("#txtSearch").keydown(function (e) { if (e.keyCode === kendo.keys.ENTER) { GetVideos(); } if (e.keyCode === kendo.keys.TAB) { GetVideos(); } }); $(document).ready(function () { $("#grid").kendoGrid({ pageable: true, serverPaging: true, dataSource: { pageSize: 5 }, height: 500, pageSize: 5, groupable: false, sortable: true, filterable: true, columnMenu: true, reorderable: false, resizable: true, pageable: true, pageable: { pageSizes: [5, 10, 25, 50, 100] }, scrollable: true }); $("#txtSearch").focus(); }); </script> </div> </body> </html> Please give solution for this problem.