zoukankan      html  css  js  c++  java
  • Ext.Net中Ext.Form.NumberField的格式化

    最近在做一个项目,在column中使用numberField时可以通过render来格式化显示数据,于是在panel这一类中使用NumberField也想格式化显示数据,于是自己就尝试些,在尝试了很多次失败后,我决定对Numberfield控件的重写:

     Ext.override(Ext.form.NumberField, {

                baseChars: "0123456789,",

                setValue: function (v) {

                    v = typeof v == 'number' ? v : String(v).replace(this.decimalSeparator,

    ".").replace(/,/g, "");

                    v = isNaN(v) ? '' : Ext.util.Format.number(

    this.fixPrecision(String(v)), "0,000,000.00");

                    this.setRawValue(v);

                },

                validateValue: function (v) {               

      var value = this.getRawValue();               

      if (!Ext.form.NumberField.superclass.validateValue.call(this, value)) {                    

    value = String(value).replace(this.decimalSeparator, ".").replace(/,/g, "");                    

    value = parseFloat(value);                    

    if (!Ext.form.NumberField.superclass.validateValue.call(this, value)) {           

                  return false;                     }

    else {

    return true; }                

    }             },

                getValue: function (v) {         

            v = this.getRawValue();               

      v = String(v).replace(this.decimalSeparator,".").replace(/,/g, "");                

    return parseFloat(v);             },            

    on: function (v) {             

        v = this.getRawValue();            

         v = String(v).replace(this.decimalSeparator,".").replace(/,/g, "");            

         this.setRawValue(v);

                }

            });

  • 相关阅读:
    【Leetcode_easy】922. Sort Array By Parity II
    【Leetcode_easy】925. Long Pressed Name
    【Leetcode_easy】872. Leaf-Similar Trees
    【Leetcode_easy】874. Walking Robot Simulation
    【Leetcode_easy】1128. Number of Equivalent Domino Pairs
    【VxWorks工程】基于opencv创建读取摄像头数据的工程error
    【Leetcode_easy】868. Binary Gap
    【Leetcode_easy】867. Transpose Matrix
    【Leetcode_easy】860. Lemonade Change
    第11章 拾遗5:IPv6和IPv4共存技术(3)_NAT-PT技术【全书完】
  • 原文地址:https://www.cnblogs.com/yycan/p/3513745.html
Copyright © 2011-2022 走看看