dont count comma separated in maxlength jqgrid column deciamal

ε祈祈猫儿з 提交于 2020-01-06 05:53:29

问题


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"
  }
},

I when edit inline record filed "PackageCode" is count decimalSeparator I want don't count decimalSeparator
see demo :https://jsfiddle.net/dnfk8hmr/288/


回答1:


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);
        }
    }
}

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:",".



来源:https://stackoverflow.com/questions/49624829/dont-count-comma-separated-in-maxlength-jqgrid-column-deciamal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!