Christian Gollhardt
Christian Gollhardt

Reputation: 17004

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?

Upvotes: 0

Views: 1544

Answers (1)

Mario Garcia
Mario Garcia

Reputation: 643

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

Upvotes: 1

Related Questions