Buttons for request only work when pressed twice

Greetings!

When performing CRUD operations, the button used for these actions doesn't work as it should when pressed for the first time.

In this first example, when pressing the "Pesquisar" (Search) button, a spinner must appear and the GET request is made, and the results are shown in the grid.

But in the first time, the only thing that happens is the GET request, which is successful, but nothing is showed on the grid.

In the second time, another request is made, and the results are displayed on the grid.




The same happens on the "Create new product" screen, when pressing the "Save" button.

It should make the Post request, show a confirmation dialog and redirect the user to another page.

But when pressing it for the first time, the request is made, and nothing else happens.

In the second time,the Post request is made again and it happens as it should.





I'm sending the code and two videos of the behavior described above.


Am I doing somehting wrong?

I appreciate your help


Best regards,


Attachment: Videos_and_Code_e01f724e.rar

1 Reply 1 reply marked as answer

JP Jeevakanth Palaniappan Syncfusion Team June 11, 2021 08:04 AM UTC

Hi Consensu, 
 
Greetings from Syncfusion support. 
 
We have checked your query and the reported problem is reproducing when the button click handler method has void return type. We suggest you to change it as Task while performing asynchronous operation. Please refer the below code snippet and the validated sample for your reference. 
 
@using Syncfusion.Blazor 
@using Syncfusion.Blazor.Grids 
@inject HttpClient Http 
 
<button @onclick="OnBtnClick">Set Datasource</button> 
 
<SfGrid DataSource="Orders" TValue="TaskList" ID="Grid" AllowPaging="true" Toolbar="@(new List<string>() { "Add", "Delete", "Update", "Cancel" })"> 
    <GridPageSettings PageSize="8"></GridPageSettings> 
    <GridEditSettings AllowEditing="true" AllowDeleting="true" AllowAdding="true" Mode="@EditMode.Normal"></GridEditSettings> 
    <GridColumns> 
        <GridColumn Field=@nameof(TaskList.OrderID) HeaderText="Order ID" IsPrimaryKey="true" TextAlign="@TextAlign.Center" Width="140"></GridColumn> 
        <GridColumn Field=@nameof(TaskList.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
    </GridColumns> 
</SfGrid> 
 
@code{ 
    public static List<TaskList> Orders { get; set; } 
 
    public async Task OnBtnClick() 
    { 
        Orders = await (Http.GetFromJsonAsync<List<TaskList>>(https://ej2services.syncfusion.com/production/web-services/api/Orders)); 
    } 
 
    public class TaskList 
    { 
        public int OrderID { get; set; } 
        public string CustomerID { get; set; } 
        public double Freight { get; set; } 
    } 
 
 
Please get back to us if you have any other queries. 
 
Regards, 
Jeevakanth SP. 


Marked as answer
Loader.
Up arrow icon