This is a migrated thread and some comments may be shown as answers.

Paging inactive on first load

2 Answers 82 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rich Lasker
Top achievements
Rank 1
Rich Lasker asked on 08 Oct 2012, 01:52 AM
Pretty simple grid that loads after you select a date range.

$(document).ready(function () {
                var start = $("#start").kendoDatePicker();
                var end = $("#end").kendoDatePicker();
                $("#load").click(function () {
                    orderDataSource.read();
                });
                var orderDataSource = new kendo.data.DataSource({
                    pageSize: 10,
                    transport: {
                        read: {
                            url: MyOrdersUrl,
                            contentType: "application/json; charset=utf-8",
                            dataType: "json",
                            data: {
                                start: function () { return $("#start").val(); },
                                end: function () { return $("#end").val(); }
                            }
                        }
                    },
                    schema: {
                        data: "d",
                        model: {
                            fields: {
                                Id: { type: "number" },
                                d_OrderDate: { type: "date", parse: parseJSONDate },
                                d_DueDate: { type: "date", parse: parseJSONDate },
                                Phone: { type: "text" },
                                Type: { type: "text" }
                            }
                        }
                    },
                });
                var grid = $("#grid").kendoGrid({
                    dataSource: orderDataSource,
                    autoBind: true,
                    filterable: true,
                    columnMenu: true,
                    sortable: true,
                    pageable: true,
                    columns: [
                    { field: "Id" },
                    { field: "d_OrderDate", title: "Order Date", format: "{0:MM/dd/yyyy}" },
                    { field: "d_DueDate", title: "Due Date", format: "{0:MM/dd/yyyy}" },
                    { field: "Type" },
                    { command: { text: "View Details", click: showOrder }, title: " ", width: "140px" }                    
    ]
 }).data("kendoGrid");
});

When you select your dates and select load the grid it populates perfectly but it is not paged and the pager arrows are inactive. If I select the drop down and change the "items per page" then the grid properly filters and pages and becomes active. Is there a way to trigger the grid to page the items after they load?

2 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 09 Oct 2012, 01:36 PM
Hello Rich,

Looking at the provided code snippet I suspect that the behavior you have described is caused by the fact that the total number of records is not return with the server response. This is required if paging is enabled and remote binding is used. Note that you should also specify the response field which holds the total number of records within the schema declaration.

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Ä m o l
Top achievements
Rank 2
answered on 11 Oct 2012, 07:40 AM
Hello Rich,

Rosen is correct!!!

here is the code you can put

just change the schema like this

  schema: {
                        data: "d",
                        total: function(result) {
                             return result.d.length;
                        },
                        model: {
                            fields: {
                                Id: { type: "number" },
                                d_OrderDate: { type: "date", parse: parseJSONDate },
                                d_DueDate: { type: "date", parse: parseJSONDate },
                                Phone: { type: "text" },
                                Type: { type: "text" }
                            }
                        }
                    }


Hope this will work for you
Tags
Grid
Asked by
Rich Lasker
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Ä m o l
Top achievements
Rank 2
Share this question
or