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. Image for the cookie policy date

Grid does not automatically refresh after saving

Hi,

I have a quite a complex Grid that after saving or deleting does not update. I can resolve the problem by force refreshing the Grid after delete and save see:

 actionComplete: (e) => {
                    if (e.requestType == 'save' || e.requestType == 'delete') {
                        DataGrid.refresh();
                    }
                }, 

However, this then hits the database twice. Why does the grid not refresh automatically? (all my other ones do)

I have attached the code for for the initialisation of of the grid

Thanks

Craig






Attachment: code_3aac96d.zip

10 Replies

MS Madhu Sudhanan P Syncfusion Team March 22, 2019 08:33 AM UTC

Hi Craig, 

Thanks for contacting Syncfusion support. 

We must need to return the edited values from server to Grid. Then only the edited values will be reflected in Grid after complete the Add and Update action. So, please ensure whether the edited values are properly returned from the server in your project. We have prepared the sample based on your requirement from your reference and you can download that sample from the below link, 


In this sample we have returned the edited values from the server while performing Add and Update action. But we do not need to return the value while perform the delete action. Please refer the following code snippet, 

public HttpResponseMessage Patch([FromODataUri]int key, [FromBody]Orders entity) 
  { 
             
           ... 
 
       return Request.CreateResponse(HttpStatusCode.OK, data); 
  } 
public HttpResponseMessage Post(Orders value) 
  { 
           ... 
 
       return Request.CreateResponse(HttpStatusCode.OK, value); 
  } 

Still If you facing the sample issue, please share the following details for further assistance, 

1)      Share your controller code snippet (i.e you have used to perform the CRUD action). 
2)      Share the network tab response. 
3)      Syncfusion package version. 

Regards, 
Madhu Sudhanan P 



CR Craig March 22, 2019 09:01 AM UTC

Hi,

I have looked at the code and it resolve the issue.

I am using a vanilla implementation of the OData 4 implementation for .NET. I have around 20 Odata controllers all structured the same way as attached and only on this one does it not work (all the return HTTP codes are correct). 

See video for the implementation: http://www.youtube.com/watch?v=Iw-vO8qRBQg

You will see in the video that the POST, PATCH OR DELETE command executes and returns correctly. The datagrid then gets new data but does not update. If I add in the manual refresh, it just calls the GET method for all the data again, just a few milliseconds afterwards.

I have attached the full source for the HTML and ODATA classes for your reference.

Regards,

Craig




Attachment: Files_af774647.zip


MS Madhu Sudhanan P Syncfusion Team March 25, 2019 07:12 AM UTC

Hi Craig, 

Thanks for your update. 

We suspect that this error might occur in the old versions. Could you please provide the grid source (ej2.min.js) version it will helpful for us to analyze further or you can also upgrade to the latest version to give it a try whether it might resolve the reported problem. 


Regards, 
Madhu Sudhanan P  



CR Craig March 25, 2019 07:14 AM UTC

Hi,

See attached

Thanks

Craig


Attachment: ej2.min.js_3b3e8dc.zip


TS Thavasianand Sankaranarayanan Syncfusion Team March 26, 2019 10:38 AM UTC

Hi Craig, 

Thanks for your update. 

Could you please share the Syncfusion nuget package version (we are not able to find out the version from ej2.min.js file.) or we request you to upgrade your packages this might resolve your problem. 


Regards, 
Thavasianand S. 



CR Craig March 26, 2019 02:15 PM UTC

The nuget version is 16.4.0.42


CR Craig March 26, 2019 02:24 PM UTC

I have upgraded to 16.4.0.54 and the issue still remains.

I wonder whether it is a timing issue as the call gets made bu the Grid does not update


MS Madhu Sudhanan P Syncfusion Team March 27, 2019 12:28 PM UTC

Hi Craig, 

Thanks for your update. 

In your application, you are enabling virtualization(mainly for large amount of data) in Grid but you are binding lower amount of data(2) so could you please confirm whether do you want to use virtualization feature in Grid? 

If this does not necessary then we suggest you to disable the virtualization and columnVirtualization feature in Grid and try again once this might solve the problem. 

Regards, 
Madhu Sudhanan P 



CR Craig March 31, 2019 01:03 PM UTC

Hi,

Where am I enabling virtualization and how can it be switched off? I have made a conscious decision to use it as this grid will not hold massive amounts of data

Craig



TS Thavasianand Sankaranarayanan Syncfusion Team April 2, 2019 09:53 AM UTC

Hi Craig, 

Thanks for your update. 
 
Query: Where am I enabling virtualization and how can it be switched off? I have made a conscious decision to use it as this grid will not hold massive amounts of data 
 
We have checked your query and you can disable the virtualization feature by setting the enableVirtualization property as false. Please refer the below code example. 

[Index.cshtml] 
var DataGrid = new ej.grids.Grid({ 
                dataSource: DataManager, 
                query: new ej.data.Query().where('Deleted', 'equal', false), 
                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true, mode: 'Normal', newRowPosition: 'Top' }, 
                allowPaging: true, 
                height: 410, 
                width: 'auto', 
                allowResizing: true, 
                enableVirtualization: false, 
                enableColumnVirtualization: false, 
                pageSettings: { pageCount: 4, pageSize: 50 }, 
                toolbar: ['Add', 'Edit', 'Delete', 'Update', 'Cancel'], 

Please refer the below documentation for getting better understanding about virtualization and where you can enable it. 


Regards, 
Thavasianand S.

Loader.
Up arrow icon