PDA

View Full Version : [OPEN-EXTJSIV-1250][B3] ComboBox null value or empty array?



mdavis6890
15 Apr 2011, 2:35 PM
Maybe it's expected behavior, I'm not sure, but it breaks my app:
getValue() returns an empty array when no option is selected.

I made this override to have it return 'null' instead, which makes more sense to me.




Ext.override(Ext.form.field.ComboBox, {
getValue: function() {
// If the user has not changed the raw field value since a value was selected from the list,
// then return the structured value from the selection. If the raw field value is different
// than what would be displayed due to selection, return that raw value.
var me = this,
picker = me.picker,
rawValue = me.getRawValue(), //current value of text field
value = me.value; //stored value from last selection or setValue() call

if (me.getDisplayValue() !== rawValue) {
value = rawValue;
me.value = me.displayTplData = me.valueModels = null;
if (picker) {
me.ignoreSelection++;
picker.getSelectionModel().deselectAll();
me.ignoreSelection--;
}
}

if(value.length == 0) {
value = null;
}

return value;
}
});