PDA

View Full Version : [Ideea] Return NULL instead of "" when nothing is set in a DateField



ValiBOSS
28 Aug 2009, 12:47 AM
After developing some applications with EXTJS (that have database servers on the backend), I began to think of the data in 2 modes:

- either it has a value
- either it has a null value

The problem is that some fields (such as DateField) return either the value either empty string (""). Instead of further processing the returned value, you can just insert the following code and anytime a DateField will have no value, NULL will be returned.


Ext.form.DateField.prototype.getValue = function() {
return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || null;
}

EXT, it would be a good ideea to implement something like "nullValue", a configurable parameter for the fields similar to DateField.

Hope this post helps anyone.