jqGrid:数字格式,逗号为小数点

8 javascript jqgrid

我使用'数字'类型将浮点数输入到jqGrid网格中.我可以格式化浮点数以逗号(我们在欧洲使用一个comman作为十进制分隔符).但是,输入字段(编辑表单或内联)仍假定输入的浮点数使用点而不是逗号.

formatoptions: {decimalSeperator : ','}
Run Code Online (Sandbox Code Playgroud)

似乎影响渲染但不影响输入数据.

这里有合理的选择吗?

Jpe*_*per 7

您可以创建自己的自定义表单.

http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter

该指南很好地解释了它.您必须创建一个formmater和一个unformmater进行编辑.

创建一个这样的格式化函数:

<script>
    jQuery("#grid_id").jqGrid({
    ...
       colModel: [ 
          ... 
          {name:'price', index:'price', width:60, align:"center", editable: true, formatter:numFormat, unformat:numUnformat},
          ...
       ]
    ...
    });

    function numFormat( cellvalue, options, rowObject ){
        return cellvalue.replace(".",",");
    }

    function numUnformat( cellvalue, options, rowObject ){
        return cellvalue.replace(",",".");
    }
</script>
Run Code Online (Sandbox Code Playgroud)

您还可以在这些函数中附加$或其他格式.