-
14 Nov 2011 1:27 PM #1
How to initialize a select field - value does not work
How to initialize a select field - value does not work
Why does this not work?
This does not set the second option - it defaults to first. value seems to work fine for text fields.Code:{ xtype: 'selectfield', options: [ {text: 'First Option', value: 'first'}, {text: 'Second Option', value: 'second'}, {text: 'Third Option', value: 'third'} ], value: 'second', }
-
16 Nov 2011 1:52 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
It looks to be a bug as in the source of Select it seems to set the value to the first record:
It could be:Code:updateOptions: function(newOptions) { var store = this.getStore(), record; if (!newOptions) { store.clearData(); this.setValue(null); } else { store.loadData(newOptions); record = store.getAt(0); this.setValue(record); } },
orCode:updateOptions: function(newOptions) { var store = this.getStore(), record; if (!newOptions) { store.clearData(); this.setValue(null); } else { store.loadData(newOptions); if (!this.record) { record = store.getAt(0); this.setValue(record); } } },
May need to do a check to see if this.record is present in the store after the loadData. If it is then use that if not then do the store.getAt(0).Code:updateOptions: function(newOptions) { var store = this.getStore(), record; if (!newOptions) { store.clearData(); this.setValue(null); } else { store.loadData(newOptions); record = this.record || store.getAt(0); this.setValue(record); } },Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
16 Nov 2011 2:04 PM #3
Ok. I assume I don't have to file this as a bug then as you prob have that handled. Thanks
-
16 Nov 2011 2:08 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 438
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
16 Dec 2011 7:31 AM #5
It seems that this bug is presented in the toggle and slide fields too. I can't initialize them with a value attribute.
-
12 Jan 2012 6:57 PM #6
This still doesn't seem to work in PR3.
Twitter: lylepratt
-
13 Jan 2012 9:12 AM #7Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,653
- Vote Rating
- 14
I'll reopen this to verify it.
-
29 May 2012 5:28 AM #8
-
11 Jun 2012 4:55 AM #9
this is working fine with me.
Code:var SelectField = new Ext.form.Select({ xtype: 'selectfield', id: 'YearFilter', name: 'Options', cls: 'x-select-dropdwn', options: [ { text: '2011', value: '2011' }, { text: '2012', value: '2012' }, { text: '2013', value: '2013' } ], listeners: { change: function (selectField, value) { console.log('Selected ' + value); } } }); SelectField.setValue('2012');
Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1048
in
2.0.


Reply With Quote