-
Notifications
You must be signed in to change notification settings - Fork 407
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] Provide alternate way to refresh when working with remote data #3423
Conversation
I agree with the CLA |
Hi, Thanks for your contribution. We will take a good look soon. You need to agree to the CLA in the format as mentioned. |
@microsoft-github-policy-service agree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Sorry it took a while to review.
There is basically only 1 change I want to see: Create a new page for the altered DataGridRemoteData sample and leave the 'old' one as-is. Now that we have separate grid sample pages it is easy to have (and good) to have more. People can compare the code of both samples to find the differences. And maybe you can also explain what the differences are in the sample page itself.
I reverted the old page, added the new example and fulfilled the requests mentioned. If you have any other points to adjust, I am at your disposal. |
Thanks for a great contribution! Just a heads-up, your |
Pull Request
📖 Description
Using ItemsProvider and Virtualize like the sample in DataGrid Remote Data the API is called 6 or 7 times. Although it has a CancellationToken in the request this is not enough to mitigate the API's resource consumption.
You can test using the code below on the screen, or seeing the calls to the api in the output:
After several failed attempts due to multiples refresh by QuickGrid and loss of sequence due to cancellation tokens. I decided to deal with the problem with a different approch.
Normally the API itself takes care of filtering, sorting and pagination, so a new type of grid update was created the 'RefreshItems'.
Basically you can define a method that will call the API.
This method is called once and only once when there is a change in the request (initial, pagination, ordering).
You must update the 'Items' and the 'SetTotalItemCountAsync'.
Along with the necessary commit, the page 'DataGridRemoteData.razor' was updated so you can see how it works.
The display of records, pagination and sorting are working.
Additionally, the option to force the datagrid refresh was added, so that if there is an API filter on the screen that has been modified, you can treat this refresh as a change in the requset.
And a new property in the column 'SortName' to facilitate the assembly of the request for the api.
🎫 Issues
#1066
👩💻 Reviewer Notes
Start the application and go to "/datagrid-remote-data" you can test here.
📑 Test Plan
I did it in a way that the old datagrid functions will not be affected if you have not defined the 'RefreshItems'.
Refresh force is optional and is set to false, so nothing changes for old things either.
And I believe that the new property in the column does not affect anything
✅ Checklist
General
Component-specific
⏭ Next Steps
Check the interaction of the grid's internal filtering with the new method