Grid issuing a server get after addRecord() call

Hi,


I am using a custom url adaptor with my grid. extendin UrlAdaptor.

I am adding a new record programically from through a button click usn

this.grid.addRecord(data, selectedRow);


I am initializing the datasource as this:

  ngAfterViewInit() { // Ensures grid is initialized before use

    this.data = new DataManager({

      url: 'http://localhost:8080/Items',

      insertUrl: 'http://localhost:8080/Items/insert',


      adaptor: new CustomUrlAdaptor(this.grid, this.loginService),

      //headers: [{ 'Authorization': `${this.loginService.getAuthorizationBearer()}` }]

    });

  }


I have seen that right after a call to addRecord, the grid issues a full fetch from the server for all the records. If there are thousands of records, this could be very time-consuming. What is the reason for this?, can it be avoided, provided that it is one record that has been added, that should be added to the grid, and the call to the server to add has worked, so it has been added. I understand that the new record may not satisfy whatever filter being applied or criteria, but would it be possible to add the new record into the grid, without needing to refetch all records?.


Many thanks in advance,

Guillermo



1 Reply

SR Sivaranjani Rajasekaran Syncfusion Team March 13, 2025 05:37 AM UTC

Hi Lejo Collada,
Greetings from Syncfusion support!
The behavior you are observing in the Syncfusion EJ2 Grid when using a CustomAdaptor that extends UrlAdaptor is expected. When performing CRUD operations with a remote data source, the grid follows a structured flow to maintain data consistency between the client and server.
When calling this.grid.addRecord(data, selectedRow), the grid first triggers a POST request to the insertUrl to send the new record to the server. Once the insertion is successful, it automatically refreshes all the records to maintain consistency.
This behavior ensures:
  • Data Consistency: The grid retrieves the latest data from the server, including any processing, transformations, or auto-generated fields (such as IDs) handled on the backend.
  • Synchronization with the Server: Refreshing the data prevents outdated information from being displayed in the grid.
This default behavior is designed to maintain data integrity and ensure accurate synchronization between the client and server.
To efficiently handle large datasets and ensure optimal performance, please refer to our best practices in the documentation:
Performance Best Practices
Please get back to us if you need further assistance.
Regards,
Sivaranjani R

Loader.
Up arrow icon