[URGENT] Grid is not refreshed when datasource.Count = 0

Hi Syncfusion, 

I just realized that my grid is not updating after I delete record from my grid via web api. 
And retrieve the records afterward, which has data count is equal to 0, which require me to trigger two times delete only then the grid refresh could work.
But it is working fine if the data source not equal to zero.

Regards, 
Khoo

3 Replies 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team December 22, 2020 07:42 AM UTC

Hi Khoo,  
 
Thanks for contacting Syncfusion support.  
 
Query: “I just realized that my grid is not updating after I delete record from my grid via web api. 
 
From your query we understand that you are facing trouble while deleting a last record in Grid component. We have validated the reported issue by preparing a DataGrid component with WebAPI Adaptor and we are not able to reproduce the reported issue at our end. Kindly download the sample from below which we have prepared using 18.4.0.30 version (Syncfusion.Blazor) Nuget package.  
 
 
After referring the sample, if you are still facing the reported issue. Kindly share the following details.  
 
  1. Are you facing the issue while using built in CRUD operation of the Grid.
  2. Share the Grid code example.
  3. Share the details about your datasource bound to Grid (i.e) using DataSource property or SfDataManager component. ‘
  4. Share more details about the issue you are facing with a video demonstration.
  5. Share details about your Syncfusion.Blazor Nuget package version
  6. If possible try to reproduce the reported issue in provided sample and revert back to us.
 
Above requested details will be helpful for us to validate the reported query at our end and provide solution as early as possible.  
 
Regards, 
Vignesh Natarajan 



KH Khoo December 22, 2020 07:51 AM UTC

I am not using WebApi adaptor. 
The datasource is bound using a model. 
But once I have updated my model value using the model from my Web API. 
The Grid is not update even I have Refresh the grid.
All CRUD operation is performed using OnBeingAction event.

The project was using v18.3.0.35 Syncfusion Blazor.


VN Vignesh Natarajan Syncfusion Team December 23, 2020 03:26 AM UTC

Hi Khoo,  
 
Thanks for sharing the requested details.  
 
Query: “The Grid is not update even I have Refresh the grid All CRUD operation is performed using OnBeingAction event. 
 
We have analyzed the provided details and we suggest you to bind the updated datasource to Grid datasource property in the OnActionComplete event of Grid when RequestType is Save. OnActionComplete event will be triggered when certain action gets completed in Grid. In that event when request type is Save, we suggest you bind the updated data (by fetching it from your service or database) to Grid datasource property.  
 
Refer the below code example.  
 
<SfGrid @ref="Grid" DataSource="@GridData" Toolbar="@(new List<string> { "Add""Edit""Delete""Cancel""Update" })" AllowFiltering="true" AllowSorting="true" AllowPaging="true"> 
    <GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings> 
    <GridEvents OnActionBegin="OnBegin" OnActionComplete="OnComplete" TValue="Order"></GridEvents> 
    <GridColumns> 
        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" IsIdentity="true" IsPrimaryKey="true" TextAlign="TextAlign.Right" Width="120"></GridColumn> 
        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn> 
        <GridColumn Field=@nameof(Order.EmployeeID) HeaderText="Id" Width="150"></GridColumn> 
    </GridColumns> 
</SfGrid> 
@code{ 
    SfGrid<Order> Grid { getset; } 
    public IEnumerable<Order> GridData { getset;} 
    protected override void OnInitialized() 
    { 
        GridData = OrderData.GetAllOrders(); 
    } 
    public async void OnComplete(ActionEventArgs<Order> Args) 
    { 
        if (Args.RequestType == Syncfusion.Blazor.Grids.Action.Save) 
        { 
            GridData = OrderData.GetAllOrders(); // fetch updated data from service and bind to grid datasource property 
        } 
    } 
 
 
Refer our UG documentation for your reference 
 
 
Please get back to us if you have further queries.  
 
Regards, 
Vignesh Natarajan 


Marked as answer
Loader.
Up arrow icon