View Full Version : How to populate select form field with a store?

19 Jul 2010, 5:39 PM
I define a select item using the code below:

xtype: 'select',
id: 'ddlAssignTo',
name: 'Assign To',
displayField: 'Name',
valueField: 'TeamId',
options: teamStore

However, the drop down is always empty? What is missing?

19 Jul 2010, 9:47 PM
It's not a store backed component:

var options = [];
value: rec.get('TeamId'),
text: rec.get('Name')

20 Jul 2010, 2:14 PM
Sorry if this is a dumb question but when I get a store and load it, the data is not available right away. When I call store.each(), like in your example, I get an error: TypeError: Result of expression 'store.each' [undefined] is not a function.
Is this because of the async loading of a store? In the store's load method if I do the callback method I can create my options array, but by that time the page is already loaded and my selects are still blank.

I am just trying to understand they way the framework handles stores because if I stick a store on dataview and put the dataview in a panel, when I load the page the panel I will have data in there.

20 Jul 2010, 5:48 PM
Yes, store loading is asynchronous, so you need to wait until the store is loaded before you can access the items.