Hi,
I am trying to generate aggregate values and place them into a element on my page. I have achieved this successfully with the following method:
Please note I have removed all irrelevant options.
$("#sh_grid").jqxGrid({ // other options here // removed for this example columns: [ { text: 'Total Value', datafield: 'total', align: 'right', cellsalign: 'right', cellsformat: 'c2' } ], ready: function(){ // Specify the localize parameters var localizationobj = {}; localizationobj.currencysymbol = "£"; $("#sh_grid").jqxGrid('localizestrings', localizationobj); // Get the sum and average values of the base total column var aggregates = $("#sh_grid").jqxGrid('getcolumnaggregateddata', 'total', ['sum', 'avg']); // Retrieve the number of filtered shipments var quantity = $("#sh_grid").jqxGrid('getdatainformation'); quantity = quantity.rowscount; // Fill in the aggregates $('#sh_quantity_aggregate').text(quantity); $('#sh_total_aggregate').text('£'+aggregates.sum); $('#sh_average_aggregate').text('£'+aggregates.avg); }});
However, there are two issues with the above method:
1. I think there is a better way to do this using the ‘custom aggregates’ field, although I am unsure how to use this.
2. The aggregate is not being formatted after it is calculated.
Therefore my questions are simply, is this the best method to place custom aggregate values outside of the grid? If so, how can I ensure the result is formatted correctly?
Thanks in advance
B