1. #1
    Ext JS Premium Member
    Join Date
    Jul 2007
    Location
    UK
    Posts
    71
    Vote Rating
    1
    AdamDawes is on a distinguished road

      0  

    Default [1.1.1][FIXED] Cannot enter zero values into NumberField controls inside EditorGrid

    [1.1.1][FIXED] Cannot enter zero values into NumberField controls inside EditorGrid


    I'm currently experiencing a problem with a NumberField inside an EditorGrid in Ext 1.1.1.

    If I enter a zero, the value is discarded and the cell is left showing an empty string. Once I have entered a non-zero value, I can then replace this with zero and the value "sticks" as expected, but putting an initial zero in just won't work.

    Searching through the forum, I happened to notice this thread which describes a very similar issue:

    http://extjs.com/forum/showthread.php?t=9855

    According to that, the problem was fixed on 4th August 2007, and I would therefore expect the fix to already be in the Ext source that I'm using, but it does appear that the problem still exists. Could anyone let me know what the fix was so that I can check my copy of the Ext source, and add it in if it's not already there?

    (Running Windows XP, tested in IE7 and Firefox 2.0.0.14 with the same results)

    Many thanks,

  2. #2
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    There have been several bugs fixed in the NumberField class since that problem was originally reported. The current code should have these two methods as below:
    Code:
        // private
        parseValue : function(value){
            value = parseFloat(String(value).replace(this.decimalSeparator, "."));
            return isNaN(value) ? '' : value;
        },
    
        // private
        fixPrecision : function(value){
            var nan = isNaN(value);
            if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
                return nan ? '' : value;
            }
            return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
        },

  3. #3
    Ext JS Premium Member
    Join Date
    Jul 2007
    Location
    UK
    Posts
    71
    Vote Rating
    1
    AdamDawes is on a distinguished road

      0  

    Default


    Hi Brian,

    Many thanks for your response. I checked the Ext codebase that I'm using and it already includes the code sections you provided so I guess I am up to date, but the problem still remains.

    I've created a simple example page that exhibits the problem. It contains a grid with two columns, "Item" which is a TextField and "Price" which is a NumberField. The Item field works fine, but entering a value of 0 into the Price field and then tabbing out results in a blank cell. The example .htm file is attached to this message.

    I've hooked the page up to use the Ext 1.1.1 source code directly from extjs.com to ensure that there's nothing peculiar in my local copy.

    Is there any chance you could take a look at this and try to identify why the value is being lost?

    Many thanks,
    Attached Files

  4. #4
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    This should do it (EDIT: Updated equality check to match 2.0, should work the same though):
    Code:
    	Ext.override(Ext.data.Record, {
    	    set : function(name, value){
    	        if(String(this.data[name]) == String(value)){
    	            return;
    	        }
    	        this.dirty = true;
    	        if(!this.modified){
    	            this.modified = {};
    	        }
    	        if(typeof this.modified[name] == 'undefined'){
    	            this.modified[name] = this.data[name];
    	        }
    	        this.data[name] = value;
    	        if(!this.editing && this.store){
    	            this.store.afterEdit(this);
    	        }
    	    }
    	});

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Location
    Austin, Texas
    Posts
    2
    Vote Rating
    0
    brian.moeskau is an unknown quantity at this point

      0  

    Default


    Fixed in SVN.

  6. #6
    Ext JS Premium Member
    Join Date
    Jul 2007
    Location
    UK
    Posts
    71
    Vote Rating
    1
    AdamDawes is on a distinguished road

      0  

    Default


    Hi Brian,

    I've added your fix to my Ext source and it looks like it's working perfectly -- thanks very much for your help!

Thread Participants: 1