PDA

View Full Version : [SOLVED] question on factory function



moegal
11 Aug 2010, 5:44 PM
Can someone help?

I have a function and I want to change the baseParams of the store without recreating the entire store if possible.



function createCombo(config) {
return new Ext.form.ComboBox(Ext.apply({
id: 'mycombo',
fieldLabel: 'Locations',
displayField: 'name',
name: 'list_ids',
mode: 'local',
triggerAction: 'all',
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: 'list.php',
method: 'post'
}),
autoLoad: true,
baseParams: {Field1: '1', Field2: '2', Field3: '3'},
fields: [{name: 'id'}, {name: 'name'}],
id: 'id',
root: 'Records'
})
}, config));
};


I realize this will not work, but could use some help. How do I pass the new baseParams in the function?



createCombo({
id: 'mynewcombo',
baseParams: {Field1: '99', Field2: '100', Field3: '101'}
})


Thanks, Marty

I changed this line in the function

From:



baseParams: {Field1: '1', Field2: '2', Field3: '3'},


To:


baseParams: config.baseParams || {Field1: '1', Field2: '2', Field3: '3'},