Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataGrid: ServerData with Virtualization #9019

Conversation

KapustinVadim1991
Copy link
Contributor

Adding virtualization support to the DataGrid when fetching data from the server via ServerData.

Description

Adding an ItemsProvider delegate to the DataGrid and passing it to the virtualization component for asynchronous fetching of list items during scrolling without a paginator.

This PR is a modification and, in my opinion, an improvement/simplification of the code from PR #7258 . In my approach, to implement virtualization combined with loading items from the server, it is sufficient to specify the ServerData and Virtualization parameters.

Type of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (fix or improvement to the website or code docs)

Checklist

  • The PR is submitted to the correct branch (dev).
  • My code follows the code style of this project.
  • I've added relevant tests.

Copy link

codecov bot commented May 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.49%. Comparing base (28bc599) to head (daa42c0).
Report is 219 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #9019      +/-   ##
==========================================
+ Coverage   89.82%   90.49%   +0.66%     
==========================================
  Files         412      394      -18     
  Lines       11878    12157     +279     
  Branches     2364     2368       +4     
==========================================
+ Hits        10670    11002     +332     
+ Misses        681      620      -61     
- Partials      527      535       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ScarletKuro
Copy link
Member

Thanks, this looks much simpler than the #7258

Copy link
Member

@ScarletKuro ScarletKuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise LGTM

src/MudBlazor/Components/Virtualize/MudVirtualize.razor.cs Outdated Show resolved Hide resolved
Copy link
Contributor

@tjscience tjscience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good aside from the call in SetParametersAsync of the MudDataGrid.

@@ -890,6 +898,7 @@ public override async Task SetParametersAsync(ParameterView parameters)
var sortModeBefore = SortMode;
await base.SetParametersAsync(parameters);

VirtualItemsProviderInitialize();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we limit calling this only when Parameters change that this feature relies on, for example, SortDefinitions and FilterDefinitions? I worry that this will be called too many times since it is in SetParametersAsync.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tjscience Good evening, you are right, I needed to add a check to avoid reinitializing the delegate, which I have now added. I didn't quite understand why we need to update the delegate when SortDefinitions/FilterDefinitions change; there might have been a misunderstanding. But if it's necessary, please let me know 😊

@ScarletKuro
Copy link
Member

@tjscience is it good to go now?

Copy link
Contributor

@tjscience tjscience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks!

@ScarletKuro ScarletKuro merged commit be27d45 into MudBlazor:dev May 23, 2024
4 checks passed
@ScarletKuro
Copy link
Member

Thanks

@KapustinVadim1991 KapustinVadim1991 deleted the feature/datagrid-server-data-virtualization branch May 23, 2024 14:22
@KapustinVadim1991
Copy link
Contributor Author

@ScarletKuro Could you please let me know if there is anything I need to do to ensure that this improvement is included in the next preview of MudBlazor v7?Or is this process documented somewhere?

@ScarletKuro
Copy link
Member

It will be automatically included in the next v7 preview, which might happen soon. Stay tuned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants