View Full Version : Getting text of select field fails when loaded from a store

26 Oct 2010, 7:24 PM
I used to get the text of the selected field like so:

var el = item.getEl();
var val;
opt = opt.dom;
val = opt.text;
return false;

But when loaded from a store, the count of items is always 0. Any idea why?

26 Oct 2010, 9:14 PM
I'm new to this, and fairly clueless on all this related to this framework, but I think I can help:

If you have a FormPanel:
var myPanel = new Ext.form.FormPanel({.....

And have a xtype: 'select' named 'userlist' that is bound to a store that has a field called 'userlist', you could use:

Hope that helps...

26 Oct 2010, 9:38 PM
When what is loaded into a store? Which items? You need to explain your problem a bit further.

27 Oct 2010, 2:59 PM
The store is loaded like this:

//this code loads it from an ajax request shortly after the app is launched.
//I can successfully retrieve the value of the select field and post it to the server.
//I just can't retrieve the text of the select field.

Ext.regModel('Team', {
fields: [
{name: 'TeamId', type: 'int'},
{name: 'Name', type: 'string'}

var teamStore = new Ext.data.JsonStore({
model : 'Team',
autoLoad : false,
autoDestroy : false

The store is used in a select field in a form like this:

items: [
xtype : 'select',
id : 'TeamId',
name: 'TeamId',
valueField: 'TeamId',
displayField: 'Name',
placeHolder: 'Select Assign To',
store : teamStore