Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-1048 in a recent build.
  1. #1
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default 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?

    Code:
    {
        xtype: 'selectfield',
        options: [
            {text: 'First Option',  value: 'first'},
            {text: 'Second Option', value: 'second'},
            {text: 'Third Option',  value: 'third'}
        ],
        value: 'second',
     }
    This does not set the second option - it defaults to first. value seems to work fine for text fields.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    It looks to be a bug as in the source of Select it seems to set the value to the first record:

    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);
            }
        },
    It could be:

    Code:
        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);
                }
            }
        },
    or

    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);
            }
        },
    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).
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User cyberwombat's Avatar
    Join Date
    Oct 2011
    Posts
    237
    Vote Rating
    2
    cyberwombat is on a distinguished road

      0  

    Default


    Ok. I assume I don't have to file this as a bug then as you prob have that handled. Thanks

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by cyberwombat View Post
    Ok. I assume I don't have to file this as a bug then as you prob have that handled. Thanks
    I will move it over. I gave you the code suggestions to help you create an override to fix it (test it first).
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha Premium Member
    Join Date
    Nov 2008
    Posts
    58
    Vote Rating
    0
    mishoboss is on a distinguished road

      0  

    Default


    It seems that this bug is presented in the toggle and slide fields too. I can't initialize them with a value attribute.

  6. #6
    Touch Premium Member lylepratt's Avatar
    Join Date
    Dec 2010
    Location
    Austin, Texas
    Posts
    159
    Vote Rating
    0
    lylepratt is on a distinguished road

      0  

    Default


    This still doesn't seem to work in PR3.
    Twitter: lylepratt

  7. #7
    Sencha - Sencha Touch Dev Team Jamie Avins's Avatar
    Join Date
    Mar 2007
    Location
    Redwood City, California
    Posts
    3,661
    Vote Rating
    20
    Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough Jamie Avins is a jewel in the rough

      0  

    Default


    I'll reopen this to verify it.

    Sencha Inc

    Jamie Avins

    @jamieavins

  8. #8
    Sencha User
    Join Date
    Jan 2012
    Posts
    20
    Vote Rating
    0
    ASraniel is on a distinguished road

      0  

    Default


    This is still a problem with version 2.0.1

  9. #9
    Sencha User
    Join Date
    Feb 2012
    Posts
    26
    Vote Rating
    0
    Syntona is on a distinguished road

      0  

    Default


    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');

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi