Hello,
i'm new to Syncfusion (version 19.2.0.57) and Blazor (server-side) too so perhaps i'm not understanding how this is supposed to work...
Right now i have a Grid and i am Updating and Deleting data on a SQL Server database through the OnActionBegin event.
This is pretty much how my grid looks like (i removed the columns because they use Templates and take a lot of space):
<SfGrid ID="GroupsGrid" @ref="GroupsGrid" DataSource="@groups" AllowPaging="true" AllowFiltering="true" AllowSorting="true">
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true" ShowDeleteConfirmDialog="true" AllowEditOnDblClick="false"></GridEditSettings>
<GridEvents OnActionBegin="ActionBeginHandler" OnActionComplete="ActionCompleteHandler" OnActionFailure="ActionFailureHandler" TValue="GroupModel"></GridEvents>
<GridColumns> .... <GridColumns> </SfGrid>
And this is how the code for the event OnActionBegin looks like:
public async Task ActionBeginHandler(ActionEventArgs<GroupModel> args)
{
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))
{
if (args.Action == "Add")
{
await GBLL.AddGroup(args.Data);
}
else
{
await GBLL.UpdGroup(args.Data);
}
}
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Delete))
{
await GBLL.DelGroupByKey(args.Data.GrpId);
}
}
public async Task ActionFailureHandler(Syncfusion.Blazor.Grids.FailureEventArgs args)
{
// This is never called
}
If any of the methods GBLL.AddGroup or GBLL.UpdGroup or GBLL.DelGroupByKey throws an exception ActionFailureHandler is not fired. I'd expect it to fire to show a message to the user, but instead the website crashes giving me the whole exception in the Console of the Browser.
Why? Shouldn't OnActionFailure fire everytime there is an exception during an action?
How am i supposed to catch exceptions and show a popup to the user with the error message?
Thank you.
|
public async Task ActionBeginHandler(ActionEventArgs<Order> args)
{
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Save))
{
if (args.Action == "Add")
{
try
{
await GBLL.AddGroup(args.Data);
}
catch (Exception Ex)
{
//catch and display the error message here
}
}
else
{
try
{
await GBLL.UpdGroup(args.Data);
}
catch (Exception Ex)
{
//catch and display the error message here
}
}
}
if (args.RequestType.Equals(Syncfusion.Blazor.Grids.Action.Delete))
{
try
{
await GBLL.DelGroupByKey(args.Data.GrpId);
}
catch (Exception Ex)
{
//catch and display the error message here
}
}
}
|
Thank you!