Hi All,
Is there a way to use a custom function to calculate a value for the footer?
i.e. at the moment I am using this snippet from the documentation page:
function grid_onload()
{
var grid = $("#list1");
// sum of displayed result
avg= grid.jqGrid('getCol', 'total', false, 'avg');
//SOME CODE REMOVED.
// record count
c = grid.jqGrid('getCol', 'id', false, 'sum');
grid.jqGrid('footerData','set', {id: 'Total: ' + sum, invdate: 'Sub Total: '+sum_running, total: 'Grand Total: '+sum_table});
};
I'd like to be able to use a custom function, specifically I need to calculate an average excluding "0" values. I have to be able to calculate at runtime as the grid is filtered by the user.
thanks,
Hamish
Hi,
You can use JS functions of grid to iterate thru all rows and calculate non-zero average.
Refer this code:
http://pastebin.com/EVWMwBc7
amount: field
list1: grid id
id: column to add footer