We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid not refreshing when new data is added

Thread ID:

Created:

Updated:

Platform:

Replies:

151139 Jan 31,2020 08:36 PM UTC Feb 21,2020 07:08 AM UTC Blazor 7
loading
Tags: Grid
Ivan Petrov
Asked On January 31, 2020 08:36 PM UTC

Hello,

I am binding data to a grid component via the DataSource property. I do it like this <Grid DataSource=MyList ... >. However when I make a call to my service and change MyList to a new list the data in the grid is not refreshed. This used to work for me in the prior versions.


Renjith Singh Rajendran [Syncfusion]
Replied On February 3, 2020 08:48 AM UTC

Hi Krasimir, 

Thanks for contacting Syncfusion support. 

We suggest you to call the “StateHasChanged” method to reflect the modified changes in Grid. We have prepared a sample based on this requirement, please download the sample form the link below, 

Please refer the code below, 

<EjsButton @onclick="ChangeData">Change Grid Data</EjsButton> 
 
<EjsGrid ID="Grid" TValue="Orders" DataSource="@OrderData" AllowPaging="true"> 
    ... 
</EjsGrid> 
 
 
@code { 
    public List<Orders> OrderData { get; set; } 
    protected override void OnInitialized() 
    { 
        OrderData = Enumerable.Range(1, 75).Select(x => new Orders() 
        { 
            OrderID = 1000 + x, 
            CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)], 
            Freight = 2.1 * x, 
            OrderDate = DateTime.Now.AddDays(-x), 
        }).ToList(); 
    } 
    public async void ChangeData() 
    { 
        OrderService _craftService = new OrderService(); 
        OrderData = await _craftService.GetOrdersAsync(); 
        StateHasChanged(); 
    } 
} 


Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Ivan Petrov
Replied On February 7, 2020 12:48 AM UTC

Yes, I know I have to invoke StateHasChanged. The grid is working in most of the places however in some of the more specific cases it is not being refreshed. This worked perfectly before but after a couple of updates to the syncfusion versions it stopped working.

Renjith Singh Rajendran [Syncfusion]
Replied On February 7, 2020 10:26 AM UTC

Hi Krasimir, 

Thanks for contacting Syncfusion support. 

Query 1 : however in some of the more specific cases it is not being refreshed 
Could you please share the complete details regarding the specific cases. Is this specific cases involve updating a single row data in Grid? If you are updating the value for a single row data(IEnumerable data in Grid) then it is a must to call the Grid’s Refresh() method to reflect the changes to Grid. Or else you can bind data to Grid as ObservableCollection.  

Please refer the documentation and online sample demos showing the CRUD with ObservableCollection as data in Grid. 
 
Query 2 : This worked perfectly before but after a couple of updates to the syncfusion versions it stopped working. 
In our older versions, we have deep watched IEnumerable changes. This had performance impacts. So to avoid this we have withdrawn IEnumerable deep watching with our latest versions. So please use the StateHasChanged method as suggested in our previous update to achieve this requirement. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Ivan Petrov
Replied On February 7, 2020 04:36 PM UTC

Yes, Refresh() fixed it for me. Didn't know about the internal state changes. Thank you for the help! :)

Renjith Singh Rajendran [Syncfusion]
Replied On February 10, 2020 09:11 AM UTC

Hi Krasimir, 

Thanks for your update. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Jelard Macalino
Replied On February 21, 2020 03:50 AM UTC

Hi I am having the same problem.  I am using an IEnumerable in the DataSource and whenever I refreshed it with a new list from my service the grid does not refresh.  I tried StateHasChanged() as recommended but it doesn't work.  I also tried refreshing the grid. It works but only on Debug but not on Release and start without debugging. Below is the error

Error: System.NullReferenceException: Object reference not set to an instance of an object.

I am using v17.4.0.49

Renjith Singh Rajendran [Syncfusion]
Replied On February 21, 2020 07:08 AM UTC

Hi Jelard, 

Thanks for contacting Syncfusion support. 

We have prepared a sample based on this reported scenario. But dynamic update of data works fine from our side. Please download the sample from the link below, 

Please refer the above sample and the suggestions which we have provided in our previous update dated 2/7/2020. And if you are still facing difficulties then we need more details to further proceed on this and provide you a solution. Kindly get back to us with the following details for better assistance. 

  1. Share the sample which you have tried from your side. Or if possible reproduce the problem with the attached sample and share with us for further validation.
  2. Share the video demo showing the problem you are facing.

The provided information will help us analyze the problem, and provide you a solution as early as possible. 

Regards, 
Renjith Singh Rajendran. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon