PDA

View Full Version : [CLOSED][3.??] Problem with NumberField as Grid Editor



asmishra
28 Apr 2009, 12:45 AM
Here is the situation which results in a bug :

Have a grid with editor of a column as NumberField with allowDecimals as false.



{
xtype : "editorgrid",
columns: [ {
header: 'foo',
editor: new Ext.form.NumberField({allowDecimals: false})
}]
]
}


Now type "4.5" in that column and if you wait, the 'keyup' event on TextField calls validate method on Field; which corrects "4.5" to "45".

But if we tabout just after typing "4.5" (without giving time for keyup event), Editor's completeEdit is called which eventually sets the value "4.5" in record.

Note: Though allowDecimals is false, isValid method on NumberField does not verify this.

After compleEdit, the 'blur' event is called on TextField which corrects "4.5" to "45" but its too late. Record has already been updated with "4.5".

Issues:
I found two issues here -

1. NumberField's validateValue does not validate for allowDecimals property.

2. Even if we fix this issue, there would be a scenario where processValue on TextField is not called and characters to be stripped (stripCharsRe) are not removed.


Solution:
1. validateValue of NumberField should verify allowDecimals.

2. Provide a getValue method on TextField which would invoke processValue.


getValue: function() {
var v = Ext.form.TextField.superclass.getValue.call(this);
return this.processValue(v);
}

mystix
28 Apr 2009, 1:15 AM
are you sure this is a problem in 3.0?
cos the decimal isn't even allowed through in both 3.0rc1 and the 2.x svn branch.
plus there's no private stripCharsRe variable in the initEvents() method in both 3.0 and 2.x svn.

i believe you're still on the official 2.2.1 release, no?

asmishra
28 Apr 2009, 10:12 PM
Its my mistake, wrong forum. We are in 2.2.1 version, waiting for final 3.0 release. Will this fix be available in 2. release?

mystix
28 Apr 2009, 10:22 PM
cos the decimal isn't even allowed through in both 3.0rc1 and the 2.x svn branch.

:)