问题
For some reason all my cfgrids drop the ending 0 of dollar amounts. So 104.50 is coming up as 104.5 and 332.80 is coming up as 332.8
It displays the last digit if it is not a 0. So 345.43 is fine.
I have tried using the currency type but that only works with flash grids.
This seems like an easy problem but I am stuck and everything I am trying is not working.
Any help on this would be great.
Thanks!
回答1:
This is for CF9 (ExtJS 3.x).
<cfsavecontent variable="formatGridInit">
<script language="javaScript">
formatgrid = function() {
var myFormatter = Ext.util.Format.numberRenderer('.00');
var mygrid = ColdFusion.Grid.getGridObject('testgrid');
var cm = mygrid.getColumnModel();
cm.setRenderer(2, myFormatter);
mygrid.reconfigure(mygrid.getStore(),cm);
};
</script>
</cfsavecontent>
<cfhtmlhead text="#formatGridInit#">
<cfset ajaxOnLoad("formatgrid")>
Make sure your HTML has <head></head>
in order for <cfhtmlhead>
to work.
replace testgrid
with your grid's name, and 2
on 2nd last line to the column index you want to apply the formatter to.
来源:https://stackoverflow.com/questions/8098332/decimal-numbers-in-a-html-cfgridcolumn