ActionHandler Data Always null

I am using Syncfusion Blazor 18.1.0.52 and when performing CRUD operations the arguments always return null.

I have tried using OnActionBegin and OnActionCompleted yet neither one return anything in args.Data

Code for Grid

@page "/Accounts"
@inject IRestClient Client

<SfGrid DataSource="@AccountCollection" AllowPaging="true" Height="200" Toolbar="@(new string[] { "Add", "Edit", "Delete", "Cancel", "Update" })">
<GridPageSettings PageSize="20"></GridPageSettings>
<GridEvents OnActionBegin="ActionCompleteHandler" TValue="Account"></GridEvents>
<GridEditSettings AllowAdding="true" AllowEditing="true" AllowDeleting="true" ShowDeleteConfirmDialog="true" Mode="EditMode.Dialog"></GridEditSettings>
<GridColumns>
<GridColumn Field="@nameof(Account.AccountId)" IsPrimaryKey="true" Visible="false"/>
<GridColumn Field="@nameof(Account.AccountName)" HeaderText="Account Name" TextAlign="TextAlign.Left"/>
</GridColumns>
</SfGrid>

@code{
private IEnumerable<Account> AccountCollection { get; set; } = new List<Account>();

public void ActionCompleteHandler(ActionEventArgs<Account> args)
{
var myData = args.Data;
}

protected override async Task OnInitializedAsync()
{
AccountCollection = Client.GetAccounts().ToList();
}

}

Head tags in _Host.cshtml

<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>PMP.ClientPortal</title>
<base rel='nofollow' href="~/"/>
<link rel="stylesheet" rel='nofollow' href="css/bootstrap/bootstrap.min.css"/>
<link rel='nofollow' href="css/site.css" rel="stylesheet"/>
<link rel='nofollow' href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet"/>
<link rel='nofollow' href="_content/Blazored.Toast/blazored-toast.min.css" rel="stylesheet"/>
<link rel='nofollow' href="https://cdn.syncfusion.com/blazor/18.1.52/styles/fabric.css" rel="stylesheet" />
<script src="https://cdn.syncfusion.com/blazor/18.1.52/syncfusion-blazor.min.js"></script>
</head>

Imports
@using Syncfusion.Blazor
@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Grids
In Startup ConfigureServices


SyncfusionLicenseProvider.RegisterLicense(Configuration["UILicenseKey"]);
services.AddSyncfusionBlazor();

3 Replies

RS Renjith Singh Rajendran Syncfusion Team May 18, 2020 11:37 AM UTC

Hi Ernest, 

Greetings from Syncfusion support. 

We suggest you to get the args.Data by checking for the corresponding action based on the RequestType as Save, Delete, Add etc. We are attaching the sample which we have tried from our side for your convenience, please download the sample from the link below, 

In the below screenshots we have shown the args.Data in both the ActionEvents, as a result of the Save action in Grid. 

                        

And if you are still facing difficulties in achieving your requirement, then we need more details to further proceed on this and provide you a solution as early as possible. Kindly share with us the following details for better assistance. 

  1. Share with us the exact scenario, you are facing this args.Data null problem.
  2. Share with us a video demo showing the replication procedure regarding this problem.
 
The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran 



EM Ernest Mallett May 18, 2020 07:09 PM UTC

I believe I have found the issue. My models are DataContracts and the DataMember name doesn't always correspond to the property name.

For example, my Account class is setup as:

[DataContract(Name = "Account")]
public class Account
{
[DataMember(Name = "Id")] public string AccountId { get; set; }

[DataMember(Name = "Name")] public string AccountName { get; set; }
}

Which doesn't work.  However when I adjust it to this:

[DataContract(Name = "Account")]
public class Account
{
[DataMember(Name = "AccountId")] public string AccountId { get; set; }

[DataMember(Name = "AccountName")] public string AccountName { get; set; }
}

Everything works as expected.  Is there a way that this functionality could be notated in the documentation for future clarification?


RS Renjith Singh Rajendran Syncfusion Team May 19, 2020 09:27 AM UTC

Hi Ernest, 

Thanks for your update.  

Based on your suggestion, we have logged a task to document this topic. We will document this topic and this will be included in any of our upcoming releases. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran 




Loader.
Up arrow icon