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

MudDataGrid: Add ability to use SortBy on TemplateColumn. #6613

Merged
merged 2 commits into from
Apr 10, 2023

Conversation

tjscience
Copy link
Contributor

Description

You can now properly use SortBy on the TemplateColumn. Before, even though the parameter was exposed, it did not work because template columns do not have a PropertyName. I have implemented the PropertyName in TemplateColumn and set it to the column's hash code so that DataGrid has a reference to each template column when sorting.

How Has This Been Tested?

Visually. Also, added unit tests.

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)

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 bug Something does not work as intended/expected PR: needs review labels Apr 9, 2023
@tjscience
Copy link
Contributor Author

@ScarletKuro, @henon

@codecov
Copy link

codecov bot commented Apr 9, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (a499a1a) 90.63% compared to head (184d91e) 90.63%.

❗ Current head 184d91e differs from pull request most recent head fe8eaa0. Consider uploading reports for the commit fe8eaa0 to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #6613   +/-   ##
=======================================
  Coverage   90.63%   90.63%           
=======================================
  Files         399      399           
  Lines       13565    13566    +1     
=======================================
+ Hits        12294    12296    +2     
+ Misses       1271     1270    -1     
Impacted Files Coverage Δ
...rc/MudBlazor/Components/DataGrid/TemplateColumn.cs 50.00% <100.00%> (+16.66%) ⬆️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ScarletKuro
Copy link
Member

ScarletKuro commented Apr 10, 2023

LGTM. Tho, in my head I was thinking more of using Guid than GetHashCode..

@henon
Copy link
Collaborator

henon commented Apr 10, 2023

MSDN under Remarks:

The default implementation of the GetHashCode method does not guarantee unique return values for different objects. Furthermore, the .NET Framework does not guarantee the default implementation of the GetHashCode method, and the value it returns will be the same between different versions of the .NET Framework. Consequently, the default implementation of this method must not be used as a unique object identifier for hashing purposes.

Copy link
Collaborator

@henon henon left a comment

Choose a reason for hiding this comment

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

LGTM, you decide about GetHashCode @tjscience

@tjscience
Copy link
Contributor Author

In my opinion, we do not need a truly unique id like GUID here. We only need uniqueness among the columns in the datagrid at any given time which GetHashCode provides easily since each TemplateColumn will be a different reference. I will change it though. It is only one line of code.

@henon henon changed the title Added ability to use SortBy on TemplateColumn. MudDataGrid: Add ability to use SortBy on TemplateColumn. Apr 10, 2023
@henon henon merged commit 367f359 into MudBlazor:dev Apr 10, 2023
1 check passed
@henon henon added the enhancement New feature or request label Apr 10, 2023
ilovepilav pushed a commit to ilovepilav/MudBlazor that referenced this pull request Nov 25, 2023
…6613)

* Added ability to use SortBy on TemplateColumn.

* CHanged PropertyName implementation in TemplateColumn from hash code to GUID.

---------

Co-authored-by: Terry Phillips <terry@nextcrew.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as intended/expected enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants