PDA

View Full Version : Store config in object notation doesn't work.



alexbrina
27 Dec 2010, 5:04 AM
Please check this code below (specially the store config), if I change the store config to store:new Ext.data.ArrayStore({...}) it works. Using store:Ext.create({...}) will work too, and this is what Ext.form.ComboBox do internally. But I need the config in json because it will receive more dynamic props further in the code, this is a simplified case just to reproduce the error. Can someone show me what's wrong? Thanks!



Ext.onReady(function(){
// combo config
var combo = {
xtype:'combo',
mode:'local',
triggerAction:'all',
valueField:'id',
displayField:'text',
store:{
xtype:'arraystore',
fields:['id', 'text'],
data:[['A', 'Text A'],['B', 'Text B']]
}
}
// simplified showcase form
var form = new Ext.FormPanel({
renderTo:Ext.getBody(),
height:200,
labelSeparator:' ',
items:[
Ext.apply({
name:'combo1',
fieldLabel:'Works nice :)'
}, combo)
,
Ext.apply({
name:'combo2',
fieldLabel:'Won\'t work :('
}, combo)
]
})
});

Condor
27 Dec 2010, 5:20 AM
Passed in config object should not be modified, but unfortunately, Ext sometimes does.

Instead of using a 'combo' config object, try creating a combo function that returns the config with the additional config applied (kind of like a combobox extension).