Get grid aggregate in javascript

Hi!

I have one grid like this:

and I have a function for loading the grid data:


So, how can I get the column aggregate after gridU.refresh to update the field above the grid?



Thanks!
Bernard.


3 Replies

PS Pavithra Subramaniyam Syncfusion Team October 21, 2021 12:54 PM UTC

Hi Bernard, 

Thanks for contacting Syncfusion support. 

You can get the aggregate value from the grid AggregateModule. Please refer to the below code example for more information. 

 
gridU.aggregateModule.footerRenderer.aggregates.aggregates['Uplata - sum'] 


Please get back to us if you need further assistance on this. 

Regards, 
Pavithra S 



BJ Bernard Jurlina October 21, 2021 03:15 PM UTC

Hi Pavithra!


Thanks for the answer. 

Yes, I tried with that, but is there some special grid event that I should do for that?

I mean, when I try like this



first time the page opens, It shows me the error:



and the grid is empty. It seems that grid is refreshed but it is not rendered on the screen.

And look what happens when I try to change the data filter.

This is the data for the month october


and when I want september




it shows me the alert before the grid was refreshed and before it displays the new data.


Thanks!

Bernard.



PS Pavithra Subramaniyam Syncfusion Team October 22, 2021 11:46 AM UTC

Hi Bernard, 

You can get the updated aggregate value inside the ‘actionComplete’ event with requestType ‘refresh’ . Please refer to the below code example and documentation link for more information 

actionComplete: (args) => { 
    if (args.requestType == 'refresh') { 
      alert(grid.aggregateModule.footerRenderer.aggregates.aggregates['Freight - sum']); 
    } 
  } 



Please get back to us if you need further assistance on this. 

Regards, 
Pavithra S 


Loader.
Up arrow icon