DataGrid Modal Dialog Save Button Not Triggering Any Events

I have a grid that works in every which way except when it comes to saving new records. The main problem is, I cannot get the event to trigger when adding a new record. It does absolutely nothing and gives no indication as to what could be wrong. I even added the OnEvenFailure="" and this event isn't being triggered either. I have other pages where this is not an issue with the exact same code so I am hard pressed as to why this page is suddenly giving me issues? Weird thing also that if I hit the Cancel button... the OnActionBegin Event fires... but nothing when I hit save?

@page "/accounts"
@using Newtonsoft.Json 
@inject IAccountRepository accountRepository

<div class="card">
    <div class="card-body">
        <h5>Accounts</h5>

        <SfGrid DataSource="@accounts" Toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })" AllowPaging="true"  AllowSelection="true" AllowSorting="true" AllowFiltering="true" EnableVirtualization="true" EnableHover="false" Height="600" RowHeight="38">
            <GridEvents TValue="Account" OnActionBegin="OnBeginHandler" OnActionFailure="ActionFailureHandler"></GridEvents>
            <GridEditSettings AllowAdding="true" AllowDeleting="true" ShowDeleteConfirmDialog="true" AllowEditing="true" Mode="EditMode.Dialog"></GridEditSettings>
            <GridColumns>
                <GridColumn Field=@nameof(Account.Active) HeaderText="Active" Width="100" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.AccountId) IsPrimaryKey="true" HeaderText="Id" Visible="false" Width="0"></GridColumn>

                <GridColumn Field=@nameof(Account.AccountType) HeaderText="Account Type" Visible="true" Width="100"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyName) HeaderText="Name" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyPhone) HeaderText="Phone" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyEmail) HeaderText="Company Email" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyAddress1) HeaderText="Address1" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyAddress2) HeaderText="Address2" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyState) HeaderText="State" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyCity) HeaderText="City" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
                <GridColumn Field=@nameof(Account.CompanyZip) HeaderText="Zip Code" Width="200" ClipMode="ClipMode.EllipsisWithTooltip"></GridColumn>
            </GridColumns>
        </SfGrid>
    </div>
</div>


@code {

    private IList<Account> accounts;

    protected override async Task OnInitializedAsync()
    {
        try
        {
            accounts = await accountRepository.Get(Endpoints.AccountsEndpoint);
        }
        catch (Exception e)
        {

        }
    }

    private async Task OnBeginHandler(ActionEventArgs<Account> Args)
    {
        //Handles add operation
        string rType = Args.RequestType.ToString();
        if (rType == "Save")
        {
            switch (Args.Action)
            {
                case "Add":
                    var a = Args.Data;
                    // Creating Accounts uses Register View Model... so translate it over.

                    var add = await accountRepository.Create(Endpoints.AccountsEndpoint, a);
                    break;
                case "Edit":
                    var edit = Args.Data;
                    var update = await accountRepository.Update(Endpoints.AccountsEndpoint, edit);
                    break;
            }

        }
        else
        {
            if (rType == "Delete")
            {
                var delete = Args.Data;
                var update = await accountRepository.Delete(Endpoints.AccountsEndpoint, delete.AccountId);
            }
        }

    }

    public void ActionFailureHandler(Syncfusion.Blazor.Grids.FailureEventArgs args)
    {
        var s = JsonConvert.DeserializeObject<Dictionary<string, object>>(JsonConvert.SerializeObject(args.Error));  //get details 
    }
}


3 Replies 1 reply marked as answer

RS Renjith Singh Rajendran Syncfusion Team February 8, 2021 12:50 PM UTC

Hi Anthony, 

Greetings from Syncfusion support. 

We have analyzed the shared codes, and we suspect that the reported problem might have occurred because of some external failure occurred with the accountRepository.Create. So we suggest you to check this problem based on this scenario from your side. 

We tried using the shared codes to reproduce the Save button in Add Dialog not working problem. But we could not reproduce this scenario with the sample created from our side. We are attaching the sample for your reference, please download the sample from the link below, 
 
Please check this case with the your Create method and also refer the above attached sample, and if you are still facing difficulties, then the following details would be helpful for us to proceed further. 

  1. Share with us a simple issue reproducing sample for us to validate based on your scenario.
  2. Share the details of any exception you have faced in browser console.
  3. Share the exact scenario you are facing this problem.
  4. Or if possible, reproduce with the above attached sample and share with us for further analysis.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith R

Marked as answer

AF Afshin January 10, 2022 05:01 PM UTC

it seems to work only on server not webassembly



RS Renjith Singh Rajendran Syncfusion Team January 11, 2022 06:59 AM UTC

Hi Afshin, 
 
We checked this scenario by creating a wasm application. The OnActionBegin handler triggers fine when pressing the Save button in Add dialog. We are attaching the sample for your reference, Please download and refer the sample from the link below, 
 
If you are still facing difficulties, kindly get back to us with the following details for better assistance. 
 
  1. Share a simple issue reproducing sample based on your scenario for us to validate.
  2. Or if possible, reproduce with the above attached sample and share with us for further analysis.
  3. Share the exact scenario you are facing the reported problem.
  4. Share a detailed explanation of the problem you are facing.
 
The provided information will help us analyze the problem, and provide you a solution as early as possible. 
 
Regards, 
Renjith R 


Loader.
Up arrow icon