简体   繁体   中英

How to set pageSizes after kendo grid is initialized?

I am basicly trying to set an "All Items"-Pagesize to kendo grid. I know I can get the total items this way:

var grid = $("#CardGrid").data("kendoGrid");
var dataSource = grid.dataSource;
dataSource.fetch(function () {
    alert(dataSource.total());
});

This is the reason I am trying to set the pagesize after the grid is initialized:

var grid = $("#CardGrid").data("kendoGrid");
console.debug(grid.options);
grid.options.pageable.pageSizes = [10, 25, 50, 100]; //This does not affect the combobox for the pagesizes

So how can I set the pagesizes?

If you want a button to show all your items, try this

$("#pager").kendoPager({
      dataSource: dataSource,
      pageSizes: [2, 3, 4, "all"]
    });

Source: http://docs.telerik.com/kendo-ui/api/javascript/ui/pager

Alternatively, try this:

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

var pageSizes = [{ text: "5", value: 5 }, { text: "10", value: 10 }, { text: "25", value: 25 },{ text: "All", value: grid.dataSource.total() }];
$('.k-pager-sizes select[data-role="dropdownlist"]').data('kendoDropDownList').setDataSource(new kendo.data.DataSource({ data: pageSizes }));​

http://www.telerik.com/forums/any-way-to-add-all-to-pagesizes-array

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM