How to set PageSize with GridPageableSettingsBuilder

1 Answer 614 Views
Grid Pager
Kazimierz
Top achievements
Rank 1
Kazimierz asked on 20 Sep 2021, 01:42 PM

Hi,

In documentation of Kendo UI for jQuery I found a property that allows to easily set page size of a grid: https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/pageable.pagesize

However, I use Kendo for ASP.NET Core, and here the PageSize property is missing: https://docs.telerik.com/aspnet-core/api/Kendo.Mvc.UI.Fluent/GridPageableSettingsBuilder

I know I can set the size on DataSource object, however I would like to have a single reusable piece of code for setting the options and current size of paging. Is the page size option hidden somewhere in GridPageableSettingsBuilder? If it is not there are there any plans to add it?

Best regards,
Kazimierz

1 Answer, 1 is accepted

Sort by
0
Stoyan
Telerik team
answered on 23 Sep 2021, 12:27 PM

Hello Kazimierz,

The Grid uses the Pager Component internally to enable pagination. However as Telerik UI for ASP.NET Core provides server-side wrappers for Kendo UI for jQuery there are some difference to the available configurations.

The GridPageableSettingsBuilder's PageSizes configuration enables the user to select the page sizes of the Grid.

.Pageable(pageable => pageable.PageSizes(new int[] {5, 10, 20, 100 }))
Instead of setting a single page size for the Component. 

That being said both Kendo UI and Telerik UI can utilize the DataSource's pageSize method to programmatically set it at runtime:

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

Alternatively, you can get the Grid's Pager field and sets it's pageSize in a similar way:

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

I hope the information above is helpful. Please let me know, if you have further questions.

Regards,
Stoyan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid Pager
Asked by
Kazimierz
Top achievements
Rank 1
Answers by
Stoyan
Telerik team
Share this question
or