圆形货币/数字(jqGrid)

时间:2014-07-30 14:26:33

标签: javascript jquery jqgrid

我有网格,我输入一个数字,例如。 15.32

如何将此数字舍入为16.00

如果我有16.01,我想将其四舍五入到17.00。这个数字总是会四舍五入。

{
    label:'Summ',
    name:'f4',
    index:'f4',
    width:120,
    search: false,
    formatter:'currency',
    formatoptions:{defaulValue:0,thousandsSeparator:' ',decimalPlaces:2,suffix:'$'}
},

1 个答案:

答案 0 :(得分:0)

您可以使用自定义格式化程序,既可以使用数字值,也可以使用后缀。 例如:

// Custom formatter that ceils all number values and suffixes .00$
function myCurrencyFormatter (cellvalue, options, rowObject)
{
    if(cellvalue == undefined) return "0.00$";
    else return Math.ceil(cellvalue) + ".00$";
}

{
    label: "Sunm",
    name:'f4',
    index:'f4',
    width:120,
    search: false,
    // Uses the custom formatter
    formatter: myCurrencyFormatter,
}

你可以在这里试试: http://jsfiddle.net/Mowday/NH498/