PDA

View Full Version : combobox doesnot cancel selection after return false



Ash2009
10 Aug 2009, 10:11 AM
Hi,
I am using the 'beforeselect' event of a combobox.I need to confirm each selection from the user by putting a dialog box of whether he really want to change it ,if the user clicks 'no' then the combo should go back to the original selection,I am returning 'false' in my code for this action but the combo still shows the new selection.the api says to return false for cancellation but it doesnt happen.please help.Do i need to give any config for this?

Heres my code,


var dispCombo = new Ext.form.ComboBox({
width:130,
fieldLabel:'Disposition',
id: 'dispCombo',
typeAhead: true,
triggerAction: 'all',
store: new Ext.data.SimpleStore({
fields: ['itemIndex','itemValue'],
data: this.dispositionEnum
}),
displayField: 'itemValue',
valueField:'itemIndex',
value:dp,
mode: 'local',
forceSelection: true,
listeners:{
scope:this,
'beforeselect':function(combo,rec,indx){
Ext.Msg.show({
title:'Confirmation',
msg: 'Do you wish to change ?',
buttons: Ext.Msg.YESNO,
icon: Ext.MessageBox.QUESTION,
scope:this,
fn: function(btn){
if(btn == 'no'){
return false; //cancel selection
}else{
//clicked yes go ahead with changes
//code removed for simplicity
}
}});
}}
});

Condor
10 Aug 2009, 11:09 AM
A messagebox is asynchronous. The beforequery function has already returned 'undefined' when the messagebox is shown and your returning false from the button handler won't have any effect.

You'll need to use this concept (http://www.extjs.com/forum/showthread.php?p=271923#post271923) to make it work.

sherpam
14 Jan 2010, 12:03 PM
I had the same problem and I tried Condor's way without success, but I've found this solution (http://www.extjs.com/forum/showthread.php?p=427457#post427457) :)