RadzenDataGrid crashes if DataGridSettings.CurrentPage exceeds PageNumbersCount #975

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

Originally created by @tpc-dsc on GitHub (Sep 6, 2023).

Describe the bug
The RadzenDataGrid crashes when loading DataGridSettings if the CurrentPage (index from 0) is greater than PageNumbersCount - 2 (which is page count + 1 for some reason). This only happens when loading dynamic data (e.g. date and time updated or state).

To Reproduce
Steps to reproduce the behavior:

  1. Using the blazor.radzen DataGrid save/load settings example, store the DataGridSettings in local browser storage.
  2. Select the last page of the DataGrid and check the CurrentPage value is set in in local browser storage.
  3. Either delete some rows from the test data, or set a filter that means there will be less data on refresh (e.g. duration < 00:00:10).
  4. Refresh the page and you'll see the whole UI freeze.

Expected behavior
An exception should be thrown without locking up the UI.

Desktop (please complete the following information):

  • OS: Windows
  • Browser Chrome and Firefox
  • "Radzen.Blazor" Version="4.15.7"

Additional context
The workaround is to clear the DataGridSettings current page index in LoadStateAsync to avoid trying to load a non-existent page.

if (_settings.CurrentPage > _dataGrid.PageNumbersCount - 2)
    _settings.CurrentPage = null;
Originally created by @tpc-dsc on GitHub (Sep 6, 2023). **Describe the bug** The RadzenDataGrid crashes when loading DataGridSettings if the CurrentPage (index from 0) is greater than PageNumbersCount - 2 (which is page count + 1 for some reason). This only happens when loading dynamic data (e.g. date and time updated or state). **To Reproduce** Steps to reproduce the behavior: 1. Using the [blazor.radzen DataGrid save/load settings example](https://blazor.radzen.com/datagrid-save-settings-loaddata), store the DataGridSettings in local browser storage. 2. Select the last page of the DataGrid and check the CurrentPage value is set in in local browser storage. 3. Either delete some rows from the test data, or set a filter that means there will be less data on refresh (e.g. duration < 00:00:10). 4. Refresh the page and you'll see the whole UI freeze. **Expected behavior** An exception should be thrown without locking up the UI. **Desktop (please complete the following information):** - OS: Windows - Browser Chrome and Firefox - "Radzen.Blazor" Version="4.15.7" **Additional context** The workaround is to clear the DataGridSettings current page index in LoadStateAsync to avoid trying to load a non-existent page. ```cs if (_settings.CurrentPage > _dataGrid.PageNumbersCount - 2) _settings.CurrentPage = null; ```
Author
Owner

@enchev commented on GitHub (Sep 6, 2023):

I navigated to the last page, filtered EmpoyeeID = 1 which will result in single page and refreshed the page - no UI freeze, no errors:
image

@enchev commented on GitHub (Sep 6, 2023): I navigated to the last page, filtered EmpoyeeID = 1 which will result in single page and refreshed the page - no UI freeze, no errors: ![image](https://github.com/radzenhq/radzen-blazor/assets/5804953/e2e03602-61b9-4252-89d5-86243827e75c)
Author
Owner

@tpc-dsc commented on GitHub (Sep 6, 2023):

This only happens when loading dynamic data (e.g. date and time updated or state).

@tpc-dsc commented on GitHub (Sep 6, 2023): > This only happens when loading dynamic data (e.g. date and time updated or state).
Author
Owner

@tpc-dsc commented on GitHub (Sep 6, 2023):

Either delete some rows from the test data, or set a filter that means there will be less data on refresh (e.g. duration < 00:00:10).

This assumes you either have a stopwatch column or you dynamically calculate the difference between a given start time and the current time.

@tpc-dsc commented on GitHub (Sep 6, 2023): > Either delete some rows from the test data, or set a filter that means there will be less data on refresh (e.g. duration < 00:00:10). This assumes you either have a stopwatch column or you dynamically calculate the difference between a given start time and the current time.
Author
Owner

@enchev commented on GitHub (Sep 6, 2023):

This assumes you either have a stopwatch column or you dynamically calculate the difference between a given start time and the current time.

I'm afraid that I'm unable to reproduce the problem nor to understand what you are saying.

@enchev commented on GitHub (Sep 6, 2023): > This assumes you either have a stopwatch column or you dynamically calculate the difference between a given start time and the current time. I'm afraid that I'm unable to reproduce the problem nor to understand what you are saying.
Author
Owner

@tpc-dsc commented on GitHub (Sep 6, 2023):

I just tried setting DataGridSettings.CurrentPage to int.MaxValue and it worked, maybe it was actually #1139 that was causing this issue. Sorry for wasting your time.

@tpc-dsc commented on GitHub (Sep 6, 2023): I just tried setting DataGridSettings.CurrentPage to int.MaxValue and it worked, maybe it was actually #1139 that was causing this issue. Sorry for wasting your time.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/radzen-blazor#975