Decimal numbers in a HTML cfgridcolumn

给你一囗甜甜゛ 提交于 2019-12-24 12:04:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!