不计算逗号在maxlength jqgrid列中分隔的逗号 [英] dont count comma separated in maxlength jqgrid column deciamal
问题描述
我有一个包含小数点和特殊字符的输入字段,例如逗号 和点,同时计算字段的maxLength,我想跳过特殊字符:
I have input field which contains decimal and special characters e.g. comma and dot while calulating the maxLength of the field i want to skip special characters :
{
name: "amount",
width: 62,
template: "number",
formatter: "number",
formatoptions: {
decimalSeparator:",",
thousandsSeparator: " ",
decimalPlaces: 4,
defaultValue: '0.0000'
},
editoptions: {
maxlength; 5
type: "number"
}
},
当我编辑内联记录字段"PackageCode"时,我计数为小数位数分隔符,我不希望计数为小数位数分隔符
参见演示: https://jsfiddle.net/dnfk8hmr/288/
I when edit inline record filed "PackageCode" is count decimalSeparator I want don't count decimalSeparator
see demo :https://jsfiddle.net/dnfk8hmr/288/
推荐答案
我不确定我是否了解您需要实现的内容.内联编辑期间,jqGrid不计算decimalSeparator
或其他值.它只是设置您使用的maxlength
的静态值(maxlength="5"
).如果需要允许编辑更多长值,例如演示中的125.22
,则可以像演示
I'm not sure that I understand what you need to implement. jqGrid don't count decimalSeparator
or anything else during inline editing. It just set static value of maxlength
, which you use (maxlength="5"
). If you need to allows to edit more long values, like 125.22
in your demo, then you can set maxlength
dynamically like in the demo https://jsfiddle.net/OlegKi/dnfk8hmr/309/, which used
editoptions: {
maxlength: 5,
dataInit: function (elem, options) {
var currentLength = String(elem.value).length;
if (currentLength > 5) {
elem.setAttribute("maxlength", currentLength);
}
}
}
此外,如果使用格式化程序选项decimalSeparator:","
,则应修复defaultValue
以使用逗号而不是点(0,00
代替0.00
或0,0000
代替0.0000
).
Additionally you should fix defaultValue
to use comma instead of dot (0,00
instead of 0.00
or 0,0000
instead of 0.0000
) if you use formatter option decimalSeparator:","
.
这篇关于不计算逗号在maxlength jqgrid列中分隔的逗号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!