Reputation: 608
I want to add some data to the footer row, which cannot be formatted correctly by the pre-defined formatter of that column. for example :
ColumnModel
{
'name': 'GDP',
'label': 'GDP',
'formatter': 'currency',
'formatOptions': {
'decimalPlaces': 2,
'defaultValue': '',
"thousandsSeparator": ',',
'prefix': '$'
},
}
but the userdata for footer is like {"GDP":"Total- 1233"}
and blank value is displayed for that footer cell. My guess is that it expects numerical data. Is there a way to assign a custom formatter for this column footer? If there is, can that custom formatter invoke pre-defined currency
formatter for the number part in "Total- 1233"
?
Upvotes: 1
Views: 2154
Reputation: 378
In this case, you need load list with the options of footerrow and userDataOnFooter like below:
footerrow : true,
userDataOnFooter : false,
You mark userDataOnFooter option as 'false' above, so you should load userdata manually in customed function of 'loadComlpete', 'gridComplete' or any one else which depends your code logic. You can code as below to manually load userdata to footer row, here I use 'loadComplete' for example:
loadComplete:function(){
var uData = jQuery("#tableId").jqGrid('getGridParam', 'userData' );
// Notice that be sure pass false to the last parameter of function,
// or jqGrid will use formatter defined in colModel option
// which in your case is 'currency' for GDP column.
jQuery("#tableId").jqGrid("footerData", "set", uData, false);
}
Besides, the method to get userdata is diffirent between old version and new versioin of jqGrid. I got a screenshot for you below:
Hope that is useful to you. :)
Upvotes: 2