PDA

View Full Version : Problem while doing a clearValue in a combo box



marxan
29 Aug 2012, 7:19 AM
Hello,

Here is my problem: I've defined 2 controls on my combo box:


'familycompocombo': { beforedeselect: me.removeRecord,
change: me.getFamilyCompo
}


Everything works fine except when I do a clearValue() of this combo. It seems that doing that calls the beforedeselect event which call my function removeRecord when it's not needed.

Is there a way to avoid this behaviour?

Thanks.

vietits
29 Aug 2012, 6:04 PM
Try to use <combo>.setValue([], false) instead of <combo>.clearValue().

marxan
30 Aug 2012, 1:35 AM
Try to use <combo>.setValue([], false) instead of <combo>.clearValue().

Thanks!

marxan
30 Aug 2012, 1:41 AM
Damned! I have another problem since I have replace clearValue by setValue([], false).

It clears the content of my combo but as my combo is a multi-select when I want to select a value in the combo, the old value are still selected even if I don't see them in combo...

vietits
30 Aug 2012, 1:49 AM
Then I think you should use a flag to indicate that you are clearing values. Example:


combo._isClearingValue = true;
combo.clearValue();
delete combo._isClearingValue;

And modify your removeRecord() method to ignore handling in case you are clearing values


removeRecord: function(combo, record, index){
if(!combo._isClearingValue){
// your handling code here
}
}

marxan
30 Aug 2012, 5:57 AM
Thanks! I didn't I could create a variable through an existing combo!

Everything is working now even though the code is a bit redundant



emptyCombo: function (){
famCompoTraps = Ext.getCmp('famCompoTraps');
awComboTraps = Ext.getCmp('awComboTraps');
ipCombo = Ext.getCmp('ipCombo');

famCompoTraps._isClearingValues = true;
awComboTraps._isClearingValues = true;
ipCombo._isClearingValues = true;

famCompoTraps.clearValue();
awComboTraps.clearValue();
ipCombo.clearValue();

delete famCompoTraps._isClearingValues;
delete awComboTraps._isClearingValues;
delete ipCombo._isClearingValues;