PDA

View Full Version : Combo with arraystore: this.proxy is undefined error



Tumac
22 Nov 2010, 9:21 AM
I am missing something. I use comboboxes all the time with remote data stores. In this case, I want a simple combo with Yes and No as the data. I am trying to use xtype: arraystore but keep getting

this.proxy is undefined error;


xtype : 'combo'
,editable : false
,width : 40
,fieldLabel : 'Active'
,name : 'active'
,valueField : 'active'
,triggerAction:'all'
,allowBlank : false
,store: {
xtype: 'arraystore'
,data : [['Y'],['N']]
,fields: [{name:'active'}]
,mode : 'local'
}

Screamy
22 Nov 2010, 9:27 AM
It's a lifecycle/initialization problem that occurs when both the combo and it's nested store are declared as xtypes. I ended up having to 'new' the store, but you can leave the combo xtyped.

Tumac
22 Nov 2010, 9:34 AM
Thanks - I wondered about that and figured I could just declare it outside my form build function and call it.

Condor
23 Nov 2010, 6:59 AM
mode:'local' is a config option of the combobox and not of the store.

Tumac
23 Nov 2010, 8:06 AM
Thanks. I fixed that as well. Here is my fix that works.


xtype : 'combo'
,editable : false
,width : 40
,fieldLabel : 'Active'
,name : 'active'
,valueField : 'active'
,displayField : 'active'
,triggerAction:'all'
,allowBlank : false
,mode:'local'
,store: new Ext.data.ArrayStore({
id : 0
,fields: ['id','active']
,data : [[1,"Y"],[2,"N"]]
})

Condor
23 Nov 2010, 8:14 AM
Why is your valueField identical to your displayField? Don't you wan't valueField:'id'?

Tumac
23 Nov 2010, 8:27 AM
Well, for whatever reason, I could not get the combo working right without the ID field. This is just a simple Y/N combobox. My preference would for it to be a checkbox, but since the checkbox won't post an unchecked value, I resorted to the drop down.

My database backend field is a Y/N ENUM type switch.

leowyatt
23 Nov 2010, 8:30 AM
Why is your valueField identical to your displayField? Don't you wan't valueField:'id'?

I think he's done that because when you choose the value from the combo box it puts the id in the field instead of the name. Or is that the wrong way to do it?

Condor
23 Nov 2010, 12:35 PM
In that case you also want hiddenName instead of name.