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

Using DataGrid RowRemoving Action #570

Closed
taylorjimbo opened this issue Feb 5, 2020 · 1 comment
Closed

Using DataGrid RowRemoving Action #570

taylorjimbo opened this issue Feb 5, 2020 · 1 comment
Labels
Type: Feature ⚙ Request or idea for a new feature.
Projects
Milestone

Comments

@taylorjimbo
Copy link

taylorjimbo commented Feb 5, 2020

I have having a time trying to implement a confirm message when the user attempts to delete a row. I have RowRemoving="@OnRowRemoving" in the DataGrid.

Here is the code:

@inject IJSRuntime JsRuntime

 private Action<CancellableRowChange<CaseRec>> OnRowRemoving = o =>
    {
      
        o.Cancel = DeleteCase(o.Item.EmployeeName); // can't call non-static method

    };

    private bool DeleteCase(string id)  // If this is static, then I can't use JsRuntime
    {

        bool confirmed = JsRuntime.InvokeAsync<bool>("confirm", "Are you sure?").Result;
        if (confirmed)
        {
            return true;
            // Delete!
        }
        return false;
    }
@stsrki
Copy link
Collaborator

stsrki commented Feb 5, 2020

Thanks for the report @taylorjimbo

I tried it on my side and the problem is that you're calling async code from synchronous method. To make it work I will have to convert RowRemoving to EventCallback that can supports async.

It will be available in the next version.

@stsrki stsrki added the Type: Feature ⚙ Request or idea for a new feature. label Feb 5, 2020
@stsrki stsrki added this to the 0.9 milestone Feb 5, 2020
@stsrki stsrki added this to Backlog in Development via automation Feb 5, 2020
@stsrki stsrki moved this from Backlog to To do in Development Feb 5, 2020
@stsrki stsrki moved this from To do to In progress in Development Feb 5, 2020
@stsrki stsrki closed this as completed Feb 5, 2020
Development automation moved this from In progress to Done Feb 5, 2020
@stsrki stsrki mentioned this issue Feb 26, 2020
60 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature ⚙ Request or idea for a new feature.
Projects
Development
  
✔ Done
Development

No branches or pull requests

2 participants