I have a JqGrid with a data footer where I would like to put the sum of a column. I would also like that when the cell value is zero in the grid, it will be gray. To do this, I created a custom formatter:
currencyFmatter = function (cellValue, options, rowObject) {
if (cellValue == 0)
return '<span class="cellWithoutBackground" style="color:#E1E1E1;">' +
$.fn.fmatter('number', cellValue, options, rowObject)
+ '</span>';
return $.fn.fmatter('number', cellValue, options, rowObject);
};
What i call so
{ name: 'Name', index: 'Name', align: 'center', width: '200px' },
{ name: 'January', index: 'Months["January"].Amount', align: 'center',
formatter:currencyFmatter}
Coloring is good, but the amount in the data footer no longer works, it always says 0.
loadComplete: function () {
var janSum = $('#jqgEndYear').jqGrid('getCol', 'January', false, 'sum');
var febSum = $('#jqgEndYear').jqGrid('getCol', 'February', false, 'sum');
var marSum = $('#jqgEndYear').jqGrid('getCol', 'March', false, 'sum');
var aprSum = $('#jqgEndYear').jqGrid('getCol', 'April', false, 'sum');
var maySum = $('#jqgEndYear').jqGrid('getCol', 'May', false, 'sum');
var junSum = $('#jqgEndYear').jqGrid('getCol', 'June', false, 'sum');
var julSum = $('#jqgEndYear').jqGrid('getCol', 'July', false, 'sum');
var augSum = $('#jqgEndYear').jqGrid('getCol', 'August', false, 'sum');
var sepSum = $('#jqgEndYear').jqGrid('getCol', 'September', false, 'sum');
var octSum = $('#jqgEndYear').jqGrid('getCol', 'October', false, 'sum');
var novSum = $('#jqgEndYear').jqGrid('getCol', 'November', false, 'sum');
var decSum = $('#jqgEndYear').jqGrid('getCol', 'December', false, 'sum');
$('#jqgEndYear').jqGrid('footerData', 'set', { Code: 'Total:',
January: janSum,
February: febSum,
March: marSum,
April: aprSum,
May: maySum,
June: junSum,
July: julSum,
August: augSum,
September: sepSum,
October: octSum,
November: novSum,
December: decSum
});
}
});
If you have an idea of โโwhy the amount will not be calculated, I will be glad to read it. Thanks in advance for your help.