PDA

View Full Version : Help with Radio groups



vibez
21 Aug 2007, 2:20 AM
Ok here is my radio group


var StatusBoth = new Ext.form.Radio({
boxLabel: 'Both',
checked: true,
id: 'StatusBoth',
name: 'dueStatus'
});

var StatusDue = new Ext.form.Radio({
boxLabel: 'Due Only',
id: 'StatusDue',
name: 'dueStatus'
});

var StatusOverdue = new Ext.form.Radio({
boxLabel: 'Overdue Only',
id: 'StatusOverdue',
name: 'dueStatus'
});



So reading the docs I see I can use getGroupValue() to see which radio is selected


filter:***.getGroupValue()

What do I put inplace of the the **** to get the getGroupValue to work?

Hers is my current [non-working] code to get the selected radio

ds.baseParams = {
filter:StatusOverdue.getGroupValue()
};

The just returns


Filter on

not the actual name/value of the radio selected

vibez
21 Aug 2007, 9:16 AM
Sorry to bump but i've simplified the example code above to hopefully make it easier to understand

Absalom
26 Aug 2007, 6:54 AM
I have the same problem. /:)



loginSuccess = function(form, action) {
alert(rememberme.getGroupValue());
}

...

fs.column({
hideLabels: true,
width: 360
},
rememberme = new Ext.form.Radio({
boxLabel: 'Save my username',
name: 'rememberme',
inputValue: 'username',
checked: remembermeUsername
}),
new Ext.form.Radio({
boxLabel: 'Save my username and password',
name: 'rememberme',
inputValue: 'both',
checked: remembermeBoth
}),
new Ext.form.Radio({
boxLabel: 'Automatic login',
name: 'rememberme',
inputValue: 'auto',
checked: remembermeAuto
})
);



It always promts "username", no matter what radio was checked during login.

jack.slocum
26 Aug 2007, 7:23 AM
Your code looks fine. Have you tried adding a debugger; statement in FireBug and actually checking the state of the radio at that point?

Absalom
26 Aug 2007, 7:35 AM
No, but you made me try something else.

I used this earlier to set the initial value:


var remembermeUsername = true;
var remembermeBoth = false;
var remembermeAuto = false;


But now I changed it to:


var remembermeUsername = false;
var remembermeBoth = true;
var remembermeAuto = false;


And now the alert says "Both". So you were right, the radios arnt actually checked when I check them. What might this be... :-?

Absalom
26 Aug 2007, 7:54 AM
Sigh...ok..solved it.

This is what caused the problem:



fs.submit({
waitMsg:'Authenticating...',
reset: true,
success: loginSuccess,
failure: loginFailure
});


Thanks for the help Jack. \:D/

Absalom
26 Aug 2007, 8:00 AM
Speaking of radios, in IE6 and 7, not FF, the radios are moved about 5 pixels to the right when checked. And then they stay there when unchecked. ~o)

Havnt seen any other reports of this. So weird..

vibez
29 Aug 2007, 12:17 AM
Speaking of radios, in IE6 and 7, not FF, the radios are moved about 5 pixels to the right when checked. And then they stay there when unchecked. ~o)

Havnt seen any other reports of this. So weird..

This has been reported here (http://extjs.com/forum/showthread.php?t=9086&highlight=radio) and a fix is posted on page two. Its a bit of a pain if you quite a few radios and checkboxes. hope 1.1.1 comes out soon

gnosis
12 Sep 2007, 10:34 AM
I'm also having trouble with this.


var c1 = new Ext.form.Radio({
fieldLabel: 'Correct',
name:'cGroup',
value:'c1',
checked:true
});

var c2 = new Ext.form.Radio({
fieldLabel: 'Correct',
name:'cGroup',
value:'c2'
});


I have a series of these, meant to specify which answer is the correct one in multiple choice quiz question form.

Based on the docs, I would expect that if I selected, say, the 3rd one and then used c6.getGroupValue() (or c2.getGroupValue()...any member of the group), the return would be "c3". Instead, the return is simply "on".

What am I missing?

Thanks,
G

gnosis
12 Sep 2007, 11:27 AM
Futher experimentation shows that, using the fields in my previous post,


console.log('c1', c1.getValue());
console.log('c1', c1.getRawValue());
console.log('c2', c2.getValue());
console.log('c2', c2.getRawValue());

Will output


c1 false
c1 on
c2 false
c2 on


Which indicates that the get[Raw]Value() functions don't actually return the value, just the state. So is there any way to get the actual value assigned to a radio button, not to mention the selected value of a group?

americos
26 Oct 2007, 8:33 AM
I have a similar issue while using getGroupValue() on radio button group. First I am getting the radio element and then calling the getGroupValue() function: Ext.get('radio').getGroupValue(); I get the error: "getGroupValue is not a function". However I can apply other public methods like: Ext.get('radio').hide(); and hide works like a charm. What I am doing wrong on getGroupValue?

americos
31 Oct 2007, 8:00 AM
I found the solution for this: http://extjs.com/forum/showthread.php?t=16573

rmeneghelli
5 Nov 2007, 9:19 AM
Hi all,
why don't you put the radio group inside a form?
In this case, you can write:

form.getValues().radioName

bye

roby

wisely
30 Dec 2007, 6:40 PM
I have the following code:

Code:

<input type="radio" id="sameAddress" value="Y"><br>
<input type="radio" id="diffAddress" value="N"><br>

<script>
Ext.test.widgets.push({init : function() {
this.component = new Ext.form.Radio({
boxLabel: 'Same as applicant Address',
name: 'GROUPNAME',
inputValue:'Y' ,
width:'auto',
checked:true
}).applyTo('sameAddress');
this.component = new Ext.form.Radio({
boxLabel: 'Not the same (Please provide details below)',
name: 'GROUPNAME',
inputValue:'N' ,
width:'auto'
}).applyTo('diffAddress');
}});
</script>

I am able to show the radio buttons but unable to click on the button??
Any idea why??

Thanks in adv.

gersonczjr
21 Nov 2008, 11:48 AM
Ext.ComponentMgr.get('radioGroupName').getGroupValue();

silverblue_phoenix
25 Mar 2009, 3:16 AM
thanks so much for this, guys. you are my life-savers. =)