PDA

View Full Version : autoSelect on Combo?



javabee
17 Dec 2010, 7:07 AM
Hi all, i'm having a couple of problems using the combo for a simpleStore? Combo populates fine but never autoSelects the first element? If i enforce selection though setValue etc then this is fine but if i try to access the value using getValue() it returns the value of the 'displayField' e.g in this case 'first'/'second' etc. If i then select an item from the list and then access the value again using getValue() then it returns 1/2/3 as would be expected? Its almost as if the 'values' are not set until the combo receives a 'select' event?



var store = new Ext.data.SimpleStore(
{
id: 'testStore',
fields: ['id','description'],
data : [['1','first'],['2','second'],['3','third']]
});

var combo = new Ext.form.ComboBox(
{
store: store,
displayField: 'description',
valueField: 'id',
mode: 'local'
});

javabee
17 Dec 2010, 7:32 AM
ok, i understand now that the autoSelect has nothing to do with selecting the first result or item in the results array. I then thought i'd found another user with the same problem at
http://www.sencha.com/forum/showthread.php?69887-combo-getValue-is-returning-display-not-value&highlight=combo+getValue+displayValue

Similar issue but the solution didn't work for me, i've tried using the ArrayStore in place of the SimpleStore but still not getting a fix :(

Graveworm
17 Dec 2010, 8:06 AM
Maybe this helps.


forceSelection : Boolean

Danek1313
17 Dec 2010, 8:20 AM
If you just want your combobox to show the first item, you can just manually hard code it like this:



var combo = new Ext.form.ComboBox(
{
store: store,
displayField: 'description',
valueField: 'id',
mode: 'local' ,
value: '1'
});