-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix multiple requests for ItemsProvider when changing the TotalItemCount #64661
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
Merged
+100
−1
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
50f7457
Implement E2E test
dariatiurina 345a8b1
Implement fix
dariatiurina e8acdfd
Clean-up
dariatiurina 3154e99
Merge branch 'main' into 62605-hash-quickgrid
dariatiurina 7ff9164
Clean-up and fix
dariatiurina 640d34c
Merge branch '62605-hash-quickgrid' of https://github.com/dariatiurin…
dariatiurina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
src/Components/test/testassets/BasicTestApp/QuickGridTest/QuickGridFilterComponent.razor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| @using Microsoft.AspNetCore.Components.QuickGrid | ||
|
|
||
| <div> | ||
| <input id="filter-input" type="text" @bind="filter" /> | ||
| <button id="apply-filter-reset-pagination-btn" @onclick="ApplyFilterResetPagination">Apply Filter</button> | ||
| <button id="apply-filter-refresh-data-btn" @onclick="ApplyFilterRefreshData">Apply Filter</button> | ||
| </div> | ||
|
|
||
| <div class="grid"> | ||
| <QuickGrid ItemsProvider="itemsProvider" Pagination="@pagination" @ref="gridRef"> | ||
| <PropertyColumn Property="@(c => c.Id)" /> | ||
| <PropertyColumn Property="@(c => c.Name)" /> | ||
| </QuickGrid> | ||
| </div> | ||
| <Paginator State="@pagination" /> | ||
|
|
||
| <p id="items-provider-calls">@itemsProviderCalls</p> | ||
|
|
||
| @code { | ||
| PaginationState pagination = new PaginationState { ItemsPerPage = 5 }; | ||
| int itemsProviderCalls = 0; | ||
| GridItemsProvider<Item> itemsProvider; | ||
dariatiurina marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| QuickGrid<Item> gridRef; | ||
| string filter = string.Empty; | ||
|
|
||
| private readonly List<Item> allItems = Enumerable.Range(1, 25) | ||
| .Select(i => new Item { Id = i, Name = $"Item {i}" }) | ||
| .ToList(); | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| itemsProvider = async request => | ||
| { | ||
| await Task.CompletedTask; | ||
|
|
||
| itemsProviderCalls++; | ||
dariatiurina marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| StateHasChanged(); | ||
|
|
||
| var filteredItems = string.IsNullOrEmpty(filter) | ||
| ? allItems | ||
| : allItems.Where(i => i.Name.Contains(filter, StringComparison.OrdinalIgnoreCase)).ToList(); | ||
|
|
||
| var totalCount = filteredItems.Count; | ||
| var pagedItems = filteredItems | ||
| .Skip(request.StartIndex) | ||
| .Take(request.Count ?? 5) | ||
| .ToList(); | ||
|
|
||
| return GridItemsProviderResult.From(pagedItems, totalCount); | ||
| }; | ||
| } | ||
|
|
||
| protected async Task ApplyFilterResetPagination() | ||
| { | ||
| await pagination.SetCurrentPageIndexAsync(0); | ||
| } | ||
|
|
||
| protected async Task ApplyFilterRefreshData() | ||
| { | ||
| await gridRef.RefreshDataAsync(); | ||
| } | ||
|
|
||
| class Item | ||
| { | ||
| public int Id { get; set; } | ||
| public string Name { get; set; } = string.Empty; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.