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

Persisting Grid PageSize Setting

2 Answers 363 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wgmleslie
Top achievements
Rank 1
wgmleslie asked on 24 Jun 2014, 11:38 AM
Hi,

I'm trying to persist the current PageSize in a grid.  To do so, I have a cookie with the previous session's PageSize in it.  On the DataBound event for the grid, I fire the following routine (uses jquery.cookie.js):

function onDataBoundBilling(e) {
    // Get cookie (if any).
    var cookiePageSize = JSON.parse($.cookie("billingPageSize"));
 
    // Push new value to PageSize.
    if ($.cookie('billingPageSize')) {
        var grid = $("#billingGrid").data("kendoGrid");
        grid.dataSource.pageSize(parseInt(cookiePageSize));
    }
}

This correctly resizes the grid to the value in the cookie.  However, the grid pager's drop down list still shows the original PageSize value.  How can I cause this to update?

2 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 26 Jun 2014, 07:55 AM
Hello William,

Please do the following:

1. Open the Grid's Basic Usage demo.

http://demos.telerik.com/kendo-ui/grid/index

2. Execute the following code in the browser's Javascript console.

var grid = $("#grid").data("kendoGrid"); grid.dataSource.pageSize(30);

The page size will change and the Grid's "Page Sizes" dropdown will show the new page size value. The only thing to note is that new custom page size values are not displayed in the dropdown's item list, unless you include them explicitly during Grid configuration:

http://docs.telerik.com/kendo-ui/api/web/grid#configuration-pageable.pageSizes

Regards,
Dimo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
wgmleslie
Top achievements
Rank 1
answered on 27 Jun 2014, 01:39 PM
Hi Dimo,

Thank you for your prompt response.

When I ran your code snippet from the command line and it worked, I realized that I need to call the .pageSize method from $(document).ready(function () not at the onDataBound event for the grid.

-Bill
Tags
Grid
Asked by
wgmleslie
Top achievements
Rank 1
Answers by
Dimo
Telerik team
wgmleslie
Top achievements
Rank 1
Share this question
or