I am using the 'number' type for entering floating point numbers into a jqGrid grid. I am able to format the floats for rendering witha comma (we use a comman in Europe as decimal seperator). However the input fields (edit form or inline) still assume that that entered floating point numbers use a dot and not a comma.
formatoptions: {decimalSeperator : ','}
seems to influcence the rendering but not the validation of the input data.
Any reasonable options here?
You can create your own custom formmaters.
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_formatter
The guide explains it well. You must create a formmater and an unformmater for editing.
Create a formatting function like this:
<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>
You can also append $ or other formatting in these functions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With