SfGrid DataSource="@ClientViewModel.ClientsL" AllowSorting="true"
So when the page is loaded I load the ClientsL list with the first 50 records from the API
(Clients.razor)
protected override async Task OnInitializedAsync()
{
await ClientViewModel.InitializeViewModelAsync();
}
(ClientsViewModel.cs)
public async Task InitializeViewModelAsync()
{
clients = await apiClientManager.GetAllClients();
}
Then when the client search I dont want the grid search on the records already loaded, because they are just 50, so I overwrite the event to conect to de API to search for the records
(Clients.razor)
public void ActionBeginHandler(ActionEventArgs args)
{
// Here you can customize your code
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Searching)
{
ClientsViewModel.SearchClients(args.SearchString);
}
}
(ClientsViewModel.cs)
public async Task SearchClients(string search)
{
clients = await apiClientManager.GetSearchClients(search);
}
It works great the API returns the records and the grid show them without a problem.
Once the grid has the records I search for, I try to order them for example by Customer Name and I click the column header, then the grid disappear, and in the console I can see this error:
Uncaught (in promise) Error: System.ArgumentException: There is no event handler associated with this event. EventId: '392'. (Parameter 'eventHandlerId')
at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
I'm not writing code to sort records on the grid, all I want is to catch the search event to connect to de API and get the records.
I tried to do what you say and cancel the event
public void ActionBeginHandler(ActionEventArgs args)
{
if (args.RequestType == Syncfusion.Blazor.Grids.Action.Searching)
{
args.Cancel = true;
ClientsViewModel.SearchClients(args.SearchString);
}
}
But then the search is not executed, so the grid never get the records from the API.
Thank you very much for your help, I really apretiate it.