View Full Version : Radiogroup loads only first time

6 Feb 2012, 6:30 AM

I use actioncolum to open the editing window for each record.
When I open the window, I use loadRecord() to load a record from grid to form.
When for the first time turn on the window, everything works normally. The second time loadRecord does not work for radio.
I checked the record and every time, everything is exactly the same.

The situation is as follows:
I took out a record with the grid and sends it to the view.

var m = e.getTarget().className.match(/\s([\w-]+)-icon/);
var rec = view.up('productcouponslist').getStore().getAt(row);
case 'coupon-change':
var window = Ext.create('AM.view.window.product.AddEditCoupon',{
edit: true,
product_restriction: rec.data.product_restriction,
couponOid: rec.data.oid

My view have radiogroup:

xtype: 'radiogroup',
labelWidth: 80,
width: 256,
columns: [100, 100],
fieldLabel: lang.discountKind.capitalize( ),
allowBlank: false,
defaults: {
name: 'rate_type'
boxLabel : lang.percentage.capitalize(),
inputValue: ':percent'
boxLabel : lang.quota.capitalize(),
inputValue: ':monetary'

I noticed after setting radio element individual names for each record. Radiogroup loads for each record only once.

defaults: {
name: 'rate_type' + recordId

Sorry form my bad english.

6 Feb 2012, 8:00 AM
How are you specifying the items in the window? I'm hoping you are doing it in initComponent and not on the prototype.

6 Feb 2012, 8:05 AM
Of course initComponent.

initComponent: function() {
this.items = [{}];

6 Feb 2012, 8:06 AM
That means every time you create a new window a new set of items is created so this would be affected by how many instances of the window is created.

6 Feb 2012, 8:10 AM
other fields such as textfields, checkbox loads well. If I change the radio on the checkbox, then it works.

6 Feb 2012, 9:52 PM
HI mitchellsimoens (http://www.sencha.com/forum/member.php?22216-mitchellsimoens) ,
Can you give an example how to set items in the prototype.I am also facing same problem.I searched in google But i have not found an example.

6 Feb 2012, 11:00 PM
I think you mean like this

items : [{
xtype: 'displayfield',
fieldLabel: 'Name',
name: 'name',
emptyText: 'Select a row'
xtype: 'displayfield',
fieldLabel: 'Email',
name: 'email',
emptyText: 'Select a row'
initComponent: function() {

But setValue() or getValue() function of displayField is not working.
Code is
var form = this.getView('developer.Viewdata');

'this' is a controller.
Error is setValue is not defined.

Thanks in advance

7 Feb 2012, 6:03 AM
No, you should do it in initComponent. Arrays and Objects outside a method can be shared among all instances if not taken care of.

8 Feb 2012, 1:58 AM
Any idea why it does not work for me?
I added that in another place, and it's loading it with no problem.
Anyway, if there will be some radiogroup with the same name then all should work globally.