RadzenDataGrid PageSize and bindSettings not working together #1009

Closed
opened 2026-01-29 17:47:43 +00:00 by claunia · 2 comments
Owner

Originally created by @andreasmuellergin on GitHub (Oct 11, 2023).

Describe the bug
When setting the PageSize (X) to the RadzenDataGrid and also using bind-Settings, changing the page size in the user interface will eventually lead to the PageSize being reinitialized with the Value X which has been defined.

To Reproduce
Steps to reproduce the behavior:

  1. Open https://blazor.radzen.com/datagrid-pager-api
  2. Set PageSize = 20 in the RadzenDataGrid
  3. Create a DataGridSettings? TheSettings {get; set;} property in the component code
  4. Set @bind-Value=TheSettings in the RadzenDataGrid
  5. Run
    -> In the UX, switch from PageSize 20 to 30 -> then switch from PageSize 30 to 10.
    -> You will notice that it keeps resetting to PageSize 20 which has been set in the xaml code

Expected behavior
Page Size should be changeable even bind-Settings is used

Desktop (please complete the following information):

Additional Information:
Not sure if it is related, it's annoying for sure.
After switching from 4.13.X to 4.17.1, creating an instance of a custom RadzenDataGrid fails if it tries to set a PageSize in its constructor due to the PageSize setter using the renderHandler which is not attached during construction.
image

Originally created by @andreasmuellergin on GitHub (Oct 11, 2023). **Describe the bug** When setting the PageSize (X) to the RadzenDataGrid and also using bind-Settings, changing the page size in the user interface will eventually lead to the PageSize being reinitialized with the Value X which has been defined. **To Reproduce** Steps to reproduce the behavior: 1. Open https://blazor.radzen.com/datagrid-pager-api 2. Set PageSize = 20 in the RadzenDataGrid 3. Create a DataGridSettings? TheSettings {get; set;} property in the component code 4. Set @bind-Value=TheSettings in the RadzenDataGrid 5. Run -> In the UX, switch from PageSize 20 to 30 -> then switch from PageSize 30 to 10. -> You will notice that it keeps resetting to PageSize 20 which has been set in the xaml code **Expected behavior** Page Size should be changeable even bind-Settings is used **Desktop (please complete the following information):** - OS: Windows - Browser: Chrome - Version: I'd assume its the most recent in https://blazor.radzen.com/datagrid-pager-api **Additional Information:** Not sure if it is related, it's annoying for sure. After switching from 4.13.X to 4.17.1, creating an instance of a custom RadzenDataGrid<T> fails if it tries to set a PageSize in its constructor due to the PageSize setter using the renderHandler which is not attached during construction. ![image](https://github.com/radzenhq/radzen-blazor/assets/44668714/7340782e-0c5f-43e6-b4a6-8150145d1927)
Author
Owner

@andreasmuellergin commented on GitHub (Oct 11, 2023):

Just noticed it can easier be reproduced by adding the pagesizeoptions and showpaging summary to this example https://blazor.radzen.com/datagrid-save-settings-loaddata

@andreasmuellergin commented on GitHub (Oct 11, 2023): Just noticed it can easier be reproduced by adding the pagesizeoptions and showpaging summary to this example https://blazor.radzen.com/datagrid-save-settings-loaddata
Author
Owner

@enchev commented on GitHub (Oct 12, 2023):

Hey @andreasmuellergin,

When binding PageSizeOption you should also set PageSize to a variable since otherwise every StateHasChanged() will reset the page size value to what is hardcoded in the razor declaration.
image
dg-pso-ps

@enchev commented on GitHub (Oct 12, 2023): Hey @andreasmuellergin, When binding PageSizeOption you should also set PageSize to a variable since otherwise every StateHasChanged() will reset the page size value to what is hardcoded in the razor declaration. ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/4b49c346-6d5b-4a73-9cdf-8b3ea8b301e3) ![dg-pso-ps](https://github.com/radzenhq/radzen-blazor/assets/5804953/9baa5fd9-3575-4952-b6fe-331afb0644bf)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#1009