Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MudDataGrid: Add post-apply edit callback (CommittedItemChanged) for form edits#12907

Merged
danielchalmers merged 4 commits into
devfrom
copilot/add-event-for-after-committeditemchanges
Mar 27, 2026
Merged

MudDataGrid: Add post-apply edit callback (CommittedItemChanged) for form edits#12907
danielchalmers merged 4 commits into
devfrom
copilot/add-event-for-after-committeditemchanges

Conversation

Copilot AI commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

MudDataGrid form editing currently invokes CommittedItemChanges before the edited values are copied back to the bound row item. This makes object-level change detection difficult when consumers need to evaluate state after the actual model mutation.

  • API addition

    • Added CommittedItemChanged to MudDataGrid<T>:
      • EventCallback<T> CommittedItemChanged { get; set; }
    • Intended for post-commit reactions on the final updated item.
  • Commit flow update

    • Form mode: CommittedItemChanged is invoked after values are copied from the edit clone to the source item.
    • Cell mode: callback is invoked after CommittedItemChanges completes (item is already edited in-place in cell mode).
    • Existing CommittedItemChanges contract and KeepOpen behavior remain unchanged.
  • Unit coverage

    • Added focused DataGrid test component + test to verify ordering:
      • CommittedItemChanges sees edited copy while source item is still unchanged.
      • CommittedItemChanged sees the source item after mutation.
  • Docs

    • Updated DataGrid editing docs to clarify CommittedItemChanged as the post-apply hook.

Example

<MudDataGrid T="OrderLine"
             Items="@Lines"
             EditMode="DataGridEditMode.Form"
             ReadOnly="false"
             CommittedItemChanges="OnCommittedItemChanges"
             CommittedItemChanged="OnCommittedItemChanged" />
private Task<DataGridEditFormAction> OnCommittedItemChanges(OrderLine editedCopy)
{
    // pre-apply hook (clone in form mode)
    return Task.FromResult(DataGridEditFormAction.Close);
}

private Task OnCommittedItemChanged(OrderLine updatedItem)
{
    // post-apply hook (bound item is now updated)
    RecomputeDirtyState();
    return Task.CompletedTask;
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add event for after committed item changes in MudDataGrid MudDataGrid: add post-apply edit callback (CommittedItemChanged) for form edits Mar 27, 2026
Copilot AI requested a review from danielchalmers March 27, 2026 14:54
@danielchalmers danielchalmers marked this pull request as ready for review March 27, 2026 14:55
@mudbot mudbot Bot changed the title MudDataGrid: add post-apply edit callback (CommittedItemChanged) for form edits MudDataGrid: Add post-apply edit callback (CommittedItemChanged) for form edits Mar 27, 2026
@mudbot mudbot Bot added API change Modifies the public API surface in a non-breaking way (ex: adds a new property) enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library labels Mar 27, 2026
@danielchalmers danielchalmers requested review from ScarletKuro and versile2 and removed request for danielchalmers March 27, 2026 14:56

@versile2 versile2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes are solid, I hate adding another event but it makes sense.

Added commit 51bac26 (docs(datagrid): brevity change with xml expansion) to tighten the DataGrid editing docs and expand the XML docs so the edit event roles are clearer:

Before:

Image

After:

Image

This is mostly wording and presentation preference. If the current phrasing does not feel right in the rendered docs, I'm completely fine undoing or reworking it as you choose.

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

Labels

API change Modifies the public API surface in a non-breaking way (ex: adds a new property) enhancement Adds a new feature or enhances existing functionality (not fixing a defect) in the main library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MudDataGrid: Add event for AFTER CommittedItemChanges

3 participants