You found a bug! We've classified it as TOUCH-4965 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    37
    Vote Rating
    2
    bumpy is on a distinguished road

      0  

    Default Radio button's setGroupValue doesn't work when called from view initialize

    Radio button's setGroupValue doesn't work when called from view initialize


    I created a simple view with 2 radio buttons and a text field.
    When I try to set a value for the text field from the view initialize method, it works fine.
    But when I try to do the same for the radio buttons using the setGroupValue method, it doesn't do anything.
    I tried delaying the setGroupValue call with setTimeout, and it did work.

    I tried debugging the issue and got to line 323 in Checkbox.js:
    element = Ext.fly(element).up('.x-field');

    element is null after that line.
    I Guess it has something to do with the DOM not being ready yet, but if it works for text fields I would expect it to work for radio buttons too.

    I used Sencha Touch 2.2.1 on Chrome 29.0.1547.

    Code:
    Ext.define('TEST.view.test', {
        extend: 'Ext.form.Panel',
        config: {
            layout : 'vbox',
            items: [
                {
                    xtype: 'radiofield',
                    name : 'field1',
                    value: '1',
                    label: '1',
                    id: 'field1'
                },
                {
                    xtype: 'radiofield',
                    name : 'field1',
                    value: '2',
                    label: '2',
                },
                {
                    xtype: 'textfield',
                    name : 'textfield',
                    value: '',
                    label: 'textfield',
                    id: 'textfield',
                },
            ]    
        },
        
        initialize: function() {
            this.callParent(arguments);
            
            var radio1 = this.down("#field1");
            
            // This doesn't work
            radio1.setGroupValue('2');
            
            // This works
            setTimeout(function() {
                radio1.setGroupValue('2');
            }, 1000);
            
            // This works
            this.down("#textfield").setValue('bla');
        },
    });

  2. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,693
    Vote Rating
    117
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

Thread Participants: 1

Tags for this Thread