PDA

View Full Version : ComboBox Bug v1.1b



cgp
15 Jun 2007, 6:40 AM
When creating a combo box on the fly (not transforming):

There is some code which hiccups while trying to set the initial value (and thereby setting the selected item) using the setValue method on the combo box:

The code is at roughly line 200 of the TextField.js source file (under forms).

I think this code is expecting the combo box to be tied to some sort of element, which it is not, so it hiccups.



setValue : function(v){
if(this.emptyText && v !== undefined && v !== null && v !== ''){
this.el.removeClass(this.emptyClass);
}
Ext.form.TextField.superclass.setValue.apply(this, arguments);
},


By putting in the test for the element, the function continues and all is happy again.



setValue : function(v){
if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){
this.el.removeClass(this.emptyClass);
}
Ext.form.TextField.superclass.setValue.apply(this, arguments);
},


Thanks. Not sure if this is the "right" fix, but it worked for me, so it is what I am using now.

cgp
15 Jun 2007, 6:43 AM
By tranforming, I meant: I was NOT converting an existing combobox or textfield into a EXT enhanced combobox.


var combo = new Ext.form.ComboBox({
store: store,
displayField:'name',
valueField: 'value',
typeAhead: true,
fieldLabel: test.display_name,
mode: 'local',
name: 'campaign_purpose',
triggerAction: 'all',
emptyText:'Select...',
selectOnFocus:true
});

combo.setValue(campaign_data.getAt(0).data.campaign_purpose);


This is my basic setup when the issue occurs. I add the combo box to a form:


form_campaign.fieldset(
{legend:'Campaign Edit'},
campaign_name,
cie_subject,
combo
)

tryanDLS
15 Jun 2007, 7:50 AM
The combobox has to be rendered before you can operate on it (setValue)

cgp
15 Jun 2007, 10:58 AM
Thank you that does seem to fix it!

The javascript I used to build my code probably should be updated somehow. While they are only using textboxes and checkboxes, I imagine the process would be the same.

http://extjs.com/learn/Tutorial:Loading_Data_Into_and_Submitting_a_Form

Again thanks.