1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    6
    Vote Rating
    0
    FELIX_LEAL is on a distinguished road

      0  

    Default the getValue() of a RadioGroup does not work

    the getValue() of a RadioGroup does not work


    Code:

    Ext.onReady(function() {
    Ext.QuickTips.init();

    Ext.create('Ext.panel.Panel', {
    renderTo: Ext.getBody(),
    height: 747,
    id: 'Panel1',
    width: 481,
    layout: {
    type: 'fit'
    },
    title: 'medical center',
    titleAlign: 'center',

    items: [{
    xtype: 'container',
    id: 'Container',
    layout: {
    type: 'absolute'
    },
    items: [{
    xtype: 'fieldcontainer',
    x: 30,
    y: 140,
    height: 230,
    id: 'FC1',
    width: 420,
    layout: {
    type: 'absolute'
    },
    fieldLabel: '* * * * * Overview * * * * *',
    labelAlign: 'top',
    labelSeparator: '',
    items: [{
    xtype: 'radiogroup',
    x: 10,
    y: 10,
    id: 'RG1',
    width: 400,
    fieldLabel: '1.- Back?',
    labelAlign: 'top',
    labelStyle: 'text-align: left',
    items: [{
    xtype: 'radiofield',
    id: 'R1',
    name: 'r1',
    boxLabel: 'Yes',
    inputValue: '1'
    },{
    xtype: 'radiofield',
    id: 'R2',
    name: 'r1',
    boxLabel: 'No',
    inputValue: '2'
    }]
    },{
    xtype: 'textareafield',
    x: 10,
    y: 110,
    id: 'TA1',
    width: 400,
    fieldLabel: '3.- suggestions',
    labelAlign: 'top',
    labelStyle: 'text-align: left',
    name: 'ta1'
    }]
    },{
    xtype: 'button',
    handler: function(button, event) {
    alert(Ext.getCmp('TA1').getValue()); *1
    alert(Ext.getCmp('RG1').getValue()); *2
    },
    x: 380,
    y: 680,
    height: 20,
    id: 'BtnSee',
    text: 'See'
    }]
    }]

    });
    });

    answer:

    alert(Ext.getCmp('TA1').getValue()); *1
    shows: the value


    alert(Ext.getCmp('RG1').getValue()); *2
    shows: [object Object]
    alert(Ext.getCmp('RG1').getValue().boxLabel); *2
    shows: undefined
    alert(Ext.getCmp('RG1').getValue()[0]); *2
    shows: undefined
    (Returns an object containing the values of all checked checkboxes within the group. Each key-value pair in the object corresponds to a checkbox name.)



    I would get the value and it is not.
    please help

  2. #2
    Sencha User existdissolve's Avatar
    Join Date
    Jan 2010
    Location
    Kansas
    Posts
    522
    Vote Rating
    86
    existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice existdissolve is just really nice

      0  

    Default


    I guess I'm not sure what you're asking. When I run your example and console.log() the result, I get:

    Code:
    {r1: "1"}
    Given that I checked the first checkbox, this is what I would expect to get back based on the documentation's description of the getValue() method for the RadioGroup.
    Before pasting your code, see if you can make a working example using Sencha Fiddle: https://fiddle.sencha.com/

    Not only will it let everyone see what you're talking about with their own eyes, but it also makes debugging your issue 19 billion times easier

    Embedding your newly created Fiddle is super-easy: Using Sencha Fiddle in the Forums

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    6
    Vote Rating
    0
    FELIX_LEAL is on a distinguished road

      0  

    Default


    ready hermanazo ... just had to do it like this:
    Ext.getCmp('RG1').getValue().r1;
    I thought only the getValue() could get the value, but I had to put the ".r1" at the end.
    Thanks for your time.

Thread Participants: 1