PDA

View Full Version : Composite field do not fire 'valid' event correctly



Traktopel
21 Jun 2010, 4:29 AM
Hello everyone,

I got something weird using compositeField, the 'valid' event is not fire by the compositeField with the following code :



Ext.onReady(function(){

var numberField = new Ext.form.NumberField({
fieldLabel: 'test',
allowDecimal : true,
allowNegative : false,
minValue : 0,
//maxValue : 555,
bubbleEvents: ['valid'],
listeners: {
'valid': function(){
alert("VALID NUMBERFIELD");
}
}
});
var combobox = new Ext.form.ComboBox({
width: 60,
bubbleEvents: ['select'],
store: [[0, 'A'], [1, 'B'], [2, 'C']],
mode: 'local',
listeners : {'select' : function(){
alert('SELECT');
}}
});

var compositeField = new Ext.form.CompositeField({
items: [numberField, combobox],
listeners: {
'valid': function(composite, newValue, oldValue){
alert("VALID COMPOSITE");
}, 'select' : function(combo, record, index){
alert("SELECT COMPOSITE");
}
}
});
var testPanel = new Ext.Panel({
layout : 'form',
items: [compositeField],
renderTo : Ext.getBody()
});

});
The only way th event to be fired is to uncomment the maxValue of the numberfield, set a wrong value in the composite field and then replace this value with a correct one ....

Is this relative to this unanswered bug post ? : http://www.sencha.com/forum/showthread.php?99515-INFOREQ-compositefield-don-t-send-any-valid-event&highlight=compositefield

Condor
21 Jun 2010, 4:46 AM
This is all caused by the fact that CompositeField isn't a real container. This will be looked at for the Ext 4 release.

You could try using something like:

compositeField.on('render', function(f){
f.relayEvents(f.innerCt, ['valid', 'select']);
});

Traktopel
21 Jun 2010, 4:49 AM
Thanks for the hook Condor

Traktopel
21 Jun 2010, 6:13 AM
There is still a problem with the 'valid' event relay ... nevertheless we can set 'combineErrors : false' to prevent compositeField to overwrite the clearInvalid and markInvalid ..... :-(