All crud operations are running successfully, just the spinner does not stop loading and new data is shown on refresh, i can handle it my own way but i want to know if you have a built in solution for this
Hi Muhammad Izhar,
Greetings from Syncfusion support.
Currently, we are validating your query and we will update further details tomorrow. Until then, we appreciate your patience.
Regards,
Nithya S
thank you, i'll be waiting for your support.
Hi Muhammad Izhar,
Thanks for your patience.
Query:” How to stop the spinner and make changes to the grid table right away?”
Based on your query, we recommend you to use state.endEdit method to stop the spinner after makings changes like editing, adding or deleting. We can save a record by invoking endEdit method while the Grid is editable. Please check the below code snippet for your reference.
|
public dataSourceChanged(state: DataSourceChangedEventArgs): void { if (state.action === 'add') { this.orderService.addRecord(state).then(() => state.endEdit()); } else if (state.action === 'edit') { this.orderService.updateRecord(state).then(() => state.endEdit()); } else if (state.requestType === 'delete') { this.orderService.deleteRecord(state).then(() => state.endEdit()); } } |
For more information, please check the below documentation.
Documentation Link:
https://ej2.syncfusion.com/react/documentation/api/grid/edit/#endedit
Kindly get back to us if you need further assistance.
Regards,
Nithya Sivaprakasam.
hi, thank you for your time!
Calling endEdit() solved the spinner problem for edit option only, add and delete still loads forever and my sourcedata is coming from sanity (a headless cms), i want changes to the table when new crud operations is completed, i'm sorry but the documentation is very confusing for me, as i have zero knowledge of typescript, can you assists on this please.
Hi Muhammad,
We are checking on your query and we will update further details on May 31st,2022.
We appreciate your patience until then.
Regards,
Nithya Sivaprakasam.
Hi Muhammad,
Sorry for the inconvenience caused. Still, we are checking your query and we will update further details on June 1st,2022.
Until then we appreciate your patience.
Regards,
Nithya Sivaprakasam.
Hi Muhammad,
Thanks for the patience.
Query: Spinner problem for add and delete option
Based on the query, we would like to inform you about dataStateChange event and the dataSourceChanged event. The dataStateChange Event triggers when you perform any grid actions like sorting, paging, filtering and grouping. It re-renders the data again in the grid.
Code example:
|
public dataStateChange(state : DataStateChangeEventArgs) { this.orderService.execute(state).then(( gridData ) => {this.grid.dataSource = gridData} ); } |
The dataSourceChanged event is triggered when the data is added, deleted and updated. We can perform the CRUD action by using action details from this event. Then we need to call the endEdit method to indicate the completion of the save operation.
In our previous update, we suggested you use the endEdit method to stop the edit operation and save the data in the grid. This would help you to hide the spinner after editing. However, we want to give clarification on why the endEdit method is not working for adding or deleting.
When we edit the row and called the endEdit method, it will complete the edit operation and refreshes the particular row in the grid. But when we add or delete the data the whole grid gets refreshed. So we should enable the dataStateChange event whenever we add or delete the data in the grid. It is mandatory to use the dataStateChange event even for sorting, paging, grouping and filtering.
Please refer to the below documentation for reference.
Documentation link:
https://ej2.syncfusion.com/react/documentation/api/grid/#datasourcechanged
https://ej2.syncfusion.com/react/documentation/api/grid/#datastatechange
https://ej2.syncfusion.com/react/documentation/api/grid/#endedit
https://ej2.syncfusion.com/react/demos/#/bootstrap5/grid/custom-binding
Please get back to us if you need further assistance.
Regards,
Nithya Sivaprakasam.