Hi. I'm trying to find the current PageSizes for a grid. I know that I can get the current PageSize with GetOptions, but I haven't find a way to get all the PageSizes.
Is there a way to do it using GetOptions? or the only way will be to get the values directly from the dropdown?
Thanks.
4 Answers, 1 is accepted
Hi Alex,
You can get all pageSizes like this:
var grid = $("#grid").data("kendoGrid");
console.log(grid.getOptions().pageable.pageSizes)
As for the currently selected option in the pageSizes dropdown, it matches the pageSize value, so you can get it as shown below:
grid.pager.pageSize()
Regards,
Ivan Danchev
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.
That worked, thanks.
Now, how can I use setOptions to set both the PageSize and PageSizes?
I can do either of them independently, but can't find a way to do it together. This is the code I use to set the PageSize:
grid.setOptions({
groupable: true
, pageable: { pageSize: selDefaultPageSize }
, dataSource: { pageSize: selDefaultPageSize }
, height: selGridHeight
});
And this is what I use the PageSizes
var selPageSizesTest = [20, 50, 100];
grid.setOptions({
groupable: true
, pageable: { pageSizes: selPageSizesTest }
, height: selGridHeight
});
Can I set them both together at the same time?
Thanks.
Alex,
The following way of setting both options worked out for me:
<input type="button" class="k-button k-primary" value="Set Page Options" onclick="setGridPageOptions()" />
<script>
function setGridPageOptions() {
var grid = $("#grid").data("kendoGrid");
var selPageSizesTest = [20, 50, 100];
var selDefaultPageSize = 50;
grid.setOptions({
groupable: true,
pageable: {
pageSizes: selPageSizesTest,
pageSize: selDefaultPageSize
},
dataSource: {
pageSize: selDefaultPageSize
},
height: 500
});
}
</script>
Try it out and let me know whether it works as expected.
Regards,
Ivan Danchev
Progress Telerik
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.