Skip to content

DataGrid: Throw exception when ServerData and QuickFilter are supplied (#7998)#8010

Merged
henon merged 1 commit intoMudBlazor:devfrom
vernou:fix/ServerData-no-QuickFilter
Jan 11, 2024
Merged

DataGrid: Throw exception when ServerData and QuickFilter are supplied (#7998)#8010
henon merged 1 commit intoMudBlazor:devfrom
vernou:fix/ServerData-no-QuickFilter

Conversation

@vernou
Copy link
Member

@vernou vernou commented Jan 10, 2024

Fix #7998

Description

The PR #4664 enable QuickFilter on data provided by ServerData.
But this has bug like describing in the PR and the ticket #7998

ServerData allows to load only the data displayed on the current page.
But QuickFilter needs all data to be loaded to work properly.
These tow parameters are exclusive.

The modification fix is to throw a exception when both parameters are supplied.

How Has This Been Tested?

A unit test was added to check the exception is correctly throw.
Also, the test that check ServerData with QuickFilter was removed.

Types 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)

This is breaking change, because all code was supplied both parameters ServerData and QuickFilter will stop to work.
But it's legit.

Checklist:

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

@github-actions github-actions bot added breaking change This change will require consumer code updates bug Unexpected behavior or functionality not working as intended PR: needs review labels Jan 10, 2024
@codecov
Copy link

codecov bot commented Jan 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f6b563b) 88.07% compared to head (371d22e) 88.08%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #8010   +/-   ##
=======================================
  Coverage   88.07%   88.08%           
=======================================
  Files         393      393           
  Lines       11742    11748    +6     
  Branches     2375     2376    +1     
=======================================
+ Hits        10342    10348    +6     
  Misses        874      874           
  Partials      526      526           

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

@vernou
Copy link
Member Author

vernou commented Jan 10, 2024

If this PR is accepted, I will do a similar PR to Items and Groupable that don't work with ServerData.
Finally, a PR to add a documentation about ServerData with some best practice.

@vernou
Copy link
Member Author

vernou commented Jan 10, 2024

@deinok, this PR revert your PR #4664. If you have a better suggestion to fix the problem and keep the feature, can you describe it in a comment?

@vernou
Copy link
Member Author

vernou commented Jan 10, 2024

@henon, can you review this PR?

@henon
Copy link
Contributor

henon commented Jan 10, 2024

@tjscience FYI

@mikes-gh
Copy link
Contributor

Normally you would query the DataSource remotely to apply the filter wouldn't you?

@henon
Copy link
Contributor

henon commented Jan 10, 2024

Yes, the quickfilter would only give you a filtered view of the current page which is not what you would expect.

@vernou
Copy link
Member Author

vernou commented Jan 10, 2024

@mikes-gh :

Normally you would query the DataSource remotely to apply the filter wouldn't you?

Yes, with ServerData all the logic must be handled externally by backend or database.


ServerData allows to load only the data displayed on the current page. It's very convenient when you work with huge datasets, because you avoid to load all elements.

QuickFilter is a delegate what work like Where in Linq to Object. So to work, it need to load all elements in memory.
The original bug, it's QuickFilter with ServerData filter only the current page... because only elements of the current page are loaded.

A solution is to load all elements and apply QuickFilter, but this loses the point of ServerData to load partially the data.
Why I suggest to disable QuickFilter when ServerData is the provider.

If you want use QuickFilter, then load all elements and set the parameter DataGrid.Items.

@henon henon merged commit 5ebb845 into MudBlazor:dev Jan 11, 2024
@henon
Copy link
Contributor

henon commented Jan 11, 2024

Thanks @vernou !

@vernou vernou deleted the fix/ServerData-no-QuickFilter branch January 11, 2024 14:47
@dennisrahmen
Copy link
Contributor

Hey @vernou did you make progress on the ServerData example for the DataGrid since there currently is none.
Would be great to get some best practices that I can start working from. ✌️

@dennisrahmen
Copy link
Contributor

If this PR is accepted, I will do a similar PR to Items and Groupable that don't work with ServerData. Finally, a PR to add a documentation about ServerData with some best practice.

Also the additional exceptions would be great. Forgot to remove mine as I am switching to ServerData for some of my DataGrids.

@vernou
Copy link
Member Author

vernou commented Jul 14, 2024

From the PR #8026, when ServerData and Items are mixed, it throw a runtime exception to advice the developer.

After I go on other thing and forget the parameter Groupable and to improve the documentation.
Nice callback.

@vernou
Copy link
Member Author

vernou commented Jul 18, 2024

@dennisrahmen
Groupable work fine with ServerData.

You can found example to use ServerData on the doc of MudTable. It's very similar.

@dennisrahmen
Copy link
Contributor

@vernou I know the example of the MudTable using that for reference in my projects.

I just had a colleague at work completely replace all DataGrids in a Project since he thought only MudTable had a ServerData example.

I was on vacation that week. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change This change will require consumer code updates bug Unexpected behavior or functionality not working as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudDataGrid QuickFilter bug with server data loading

4 participants