Multiple Requests on each change in datagrid

Hi,

When I use the following code to update the data grid, it triggers multiple requests for each event. I'm getting three requests in my scenario. How to avoid this and make a single request.

var grid = dataGrid.value.$el.ej2_instances[0]
grid.pageSettings.currentPage = 1
  grid.query = query
  grid.refresh()

3 Replies 1 reply marked as answer

RS Rajapandiyan Settu Syncfusion Team August 4, 2022 02:11 PM UTC

Hi Boopathy,


Thanks for contacting Syncfusion support.


When you change the Grid properties programmatically, Grid will automatically get refreshed and send a request to the server. If you change multiple properties at a time, it refreshes the Grid multiple times and sends multiple requests to the server. This is the behavior of Grid.


If you want to apply multiple changes in the Grid with a single refresh, you can achieve this by using setProperties and freezeRefresh methods.


 

    btnClick: function (args) {

      var query = new Query();

      var grid = this.$refs.grid.ej2Instances;

      grid.setProperties(

        {

          pageSettings: { currentPage: 1 }, // change the page settings

          query: query,  // change the grid query

          sortSettings: { columns: [] },  // clear the sort settings

        },

       true);  // change the Grid properties without refresh

      grid.freezeRefresh();  // refresh the grid

    }

 


Sample: https://codesandbox.io/s/vue-template-forked-0tw7kg?file=/src/App.vue


Please get back to us if you need further assistance.


Regards,

Rajapandiyan S


Marked as answer

BO Boopathy August 4, 2022 06:06 PM UTC

Thank you Rajapandiyan.



RS Rajapandiyan Settu Syncfusion Team August 5, 2022 04:11 AM UTC

Hi Boopathy,


We are glad to hear that you have achieved your requirement with the solution provided.


Please get back to us if you need further assistance.


Regards,

Rajapandiyan S


Loader.
Up arrow icon