Here is the code I am using:
<table class="easyui-datagrid" id="stockdg"
data-options="
url:'getinventory.php',
rowNumbers:'true',
pagination:'true' ,
pageSize:20,
showFooter:'true',
fitColumns:'true',
onLoadSuccess:function(){
$(this).datagrid('reloadFooter',[
{clAvgPrice: '', clAmount: ''}//This does not return black but returns NaN
]);
}">
<thead>
<tr>
<th field="drugName" width="auto" sortable="true" align="left">Drugs</th>
<th field="unit" width="auto" sortable="true" align="center">Unit</th>
<th field="opQnt" formatter="formatAny" width="auto" sortable="true" align="right">Op.Qty</th>
<th field="opCost" formatter="formatAny" width="auto" sortable="true" align="right">Avg.Price</th>
<th field="opAmt" formatter="formatAny" width="auto" sortable="true" align="right">Op.Amt</th>
<th field="prQnt" formatter="formatAny" width="auto" sortable="true" align="right">Purc.</th>
<th field="prCost" formatter="formatAny" width="auto" sortable="true" align="right">Avg.Price</th>
<th field="prAmt" formatter="formatAny" width="auto" sortable="true" align="right">Purc.Amt</th>
<th field="qntOrdered" formatter="formatAny" width="auto" sortable="true" align="rightr">Sale</th>
<th field="slPrice" formatter="formatAny" width="auto" sortable="true" align="right">Avg.Price</th>
<th field="slAmt" formatter="formatAny" width="auto" sortable="true" align="right">Sale Amt</th>
<th field="closeAmount" formatter="formatAny" width="auto" sortable="true" align="right">Clt.Qty</th>
<th field="clAvgPrice" formatter="formatAny" width="auto" sortable="true" align="right">Avg.Price</th>
<th field="clAmount" formatter="formatAny" width="auto" sortable="true" align="right">Cl.Amt</th>
</tr>
</thead>
</table>
<script>
function formatAny(val,row){
if(val){
return parseFloat(val).toFixed(2);
}else{
return '0.00';
}
}
</script>
getinventory.php returns the following JSON:
JSON=
'{
"total":2,
"rows":[{
"drugName":"Speed",
"unit":"Bottle",
"opQnt":"500.00",
"opCost":"50.000000",
"opAmt":"25000.000000",
"prQnt":"0.00",
"prCost":"0.000000",
"prAmt":"0.000000",
"qntOrdered":"2.00",
"slPrice":"80.000000",
"slAmt":"160.000000",
"closeAmount":"498.00",
"clAvgPrice":"43.33333333333334",
"clAmount":"21580.00000000000000"
},{
"drugName":"Shark",
"unit":"Bottle",
"opQnt":"100.00",
"opCost":"50.000000",
"opAmt":"5000.000000",
"prQnt":"0.00",
"prCost":"0.000000",
"prAmt":"0.000000",
"qntOrdered":"5.00",
"slPrice":"80.000000",
"slAmt":"720.000000",
"closeAmount":"95.00",
"clAvgPrice":"43.33333333333334",
"clAmount":"4116.66666666666700"
}],
"footer":[{
"drugName":"Total",
"opQnt":"600.00",
"opCost":"100.000000",
"opAmt":"30000.000000",
"prQnt":"0.00",
"prCost":"0.000000",
"prAmt":"0.000000",
"qntOrdered":"7.00",
"slPrice":"160.000000",
"slAmt":"880.000000",
"closeAmount":"593.00",
"clAvgPrice":" ",
"clAmount":" "
}]
}';