HTML cfgridcolumn中的小数 [英] Decimal numbers in a HTML cfgridcolumn

查看:100
本文介绍了HTML cfgridcolumn中的小数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,我所有的cfgrids都将美元金额的结尾0掉了.因此104.50上升为104.5,而332.80上升为332.8

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

如果不是0,则显示最后一位.所以345.43可以.

It displays the last digit if it is not a 0. So 345.43 is fine.

我尝试使用货币类型,但仅适用于Flash网格.

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.

谢谢!

推荐答案

这是用于CF9(ExtJS 3.x).

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")>

确保HTML具有<head></head>,以便<cfhtmlhead>正常工作.

Make sure your HTML has <head></head> in order for <cfhtmlhead> to work.

用网格的名称替换testgrid,并在最后一行的第二行将2替换为您要应用格式程序的列索引.

replace testgrid with your grid's name, and 2 on 2nd last line to the column index you want to apply the formatter to.

这篇关于HTML cfgridcolumn中的小数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆