Blazorise: How to intercept Cancel button press in datagrid

Created on 11 Oct 2019  路  1Comment  路  Source: stsrki/Blazorise

I've built my own validation mechanism for the DataGrid which displays ValidationResults in a blazorise Alert. I would like to Hide() the alert when a user wants to cancel editing a row.

Pressing Cancel goes through to context.Clicked which I can't override without breaking the row cancellation. How would I add functionality to the cancel request?

Alternatively can you provide an OnCancelingEdit event that I can use in a future release?

Most helpful comment

Context is used to handle the events by the outside components. Nothing stops you from using your own event handlers.

eg.

void MyCancelHandler( CommandContext commandContext )
{
    alert.Hide();

    commandContext.Clicked.InvokeAsync( null );
}
<CancelCommandTemplate>
    <Button Color="Color.Secondary" Clicked="@((e)=>MyCancelHandler(context))">Cancel</Button>
</CancelCommandTemplate>

>All comments

Context is used to handle the events by the outside components. Nothing stops you from using your own event handlers.

eg.

void MyCancelHandler( CommandContext commandContext )
{
    alert.Hide();

    commandContext.Clicked.InvokeAsync( null );
}
<CancelCommandTemplate>
    <Button Color="Color.Secondary" Clicked="@((e)=>MyCancelHandler(context))">Cancel</Button>
</CancelCommandTemplate>
Was this page helpful?
0 / 5 - 0 ratings