PDA

View Full Version : Load selectfield options from store?



irocker
14 Feb 2011, 1:23 PM
I have a selectfield in a form and I want the select text and values to be loaded from a database (via a store) as opposed to hard coded. Is there a way to do this? I don't need to dynamically change the options once the form is loaded, just need to populate the selection picker with options from the store when the form is opened.

Rhoover
11 Apr 2011, 1:49 PM
for anyone who it may help, i've got it to work thus:


Ext.regModel('Category',{
fields:[
{name:'categoryName',type:'string'},
{name:'categoryTitle',type:'string'}
]
});

along with:


Ext.regStore('categoryStore',{
model:'Category',
autoLoad:true,
autoDestroy:true,
data : [
{categoryName:'ale',categoryTitle:'Ale'},
{categoryName:'lager',categoryTitle:'Lager'},
{categoryName:'hybrid',categoryTitle:'Hybrid - Other'}
]
});

and finally:



....

{xtype:'fieldset',title:'Brew Category (tap to select):',defaults:{labelAlign:'left',labelWidth:'33%'},
items: [
{xtype:'pickerselectfield',
name:'categoryName',
valueField:'categoryName',
displayField:'categoryTitle',
store:Ext.getStore('categoryStore')}
]
},

where this noob is stumped though is creating a picker with multiple slots populated by different stores.

the custom picker examples 'round here are all date related, really helpful but not on-topic for my needs.

any thoughts?