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

MudTable: Add ability to control which rows are editable #8873

Merged
merged 1 commit into from
May 7, 2024

Conversation

biegehydra
Copy link
Contributor

Reopened #7787 because that PR became a mess

Description

It would be useful to have control over which items are editable on a per row basis. Often times there are certain records that you don't want to allow to be edited. This PR lets you provide a Func<T, bool> to control which items are editable.

This is accomplished by treating IsEditable on the MudTr and IsEditable on the MudTable as separate values where previously they were essentially the same.

Here's a quick example where editing is only allowed when the temperature is greater than 20.

2023-11-20.01-43-30.mp4

How Has This Been Tested?

  • Unit tests
  • Visually

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)

I don't really think this is a breaking change, but I am sure there is some edge case that is affected by this change.

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 enhancement New feature or request PR: needs review labels May 4, 2024
Copy link

codecov bot commented May 4, 2024

Codecov Report

Attention: Patch coverage is 77.77778% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 90.24%. Comparing base (28bc599) to head (493d7e1).
Report is 158 commits behind head on dev.

Files Patch % Lines
src/MudBlazor/Components/Table/MudTr.razor 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev    #8873      +/-   ##
==========================================
+ Coverage   89.82%   90.24%   +0.41%     
==========================================
  Files         412      425      +13     
  Lines       11878    12292     +414     
  Branches     2364     2409      +45     
==========================================
+ Hits        10670    11093     +423     
+ Misses        681      668      -13     
- Partials      527      531       +4     

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

@@ -114,6 +114,8 @@ private EventCallback<MouseEventArgs> RowMouseLeaveEventCallback

private void StartEditingItem(bool buttonClicked)
{
if (!IsEditable) return;
Copy link
Member

Choose a reason for hiding this comment

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

@henon doesn't seems like your statement is correct #7787 (comment)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I was mistaken, the rename will be done via #8892 which is not yet merged.

@ScarletKuro ScarletKuro requested a review from henon May 6, 2024 12:06
@ScarletKuro ScarletKuro mentioned this pull request May 6, 2024
7 tasks
@henon henon merged commit c17e606 into MudBlazor:dev May 7, 2024
3 of 4 checks passed
@henon
Copy link
Collaborator

henon commented May 7, 2024

Thanks @biegehydra

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