PDA

View Full Version : Radiogroup loads only first time



dmN86
6 Feb 2012, 6:30 AM
Hi,

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);
if(m){
switch(m[1]){
case 'coupon-change':
var window = Ext.create('AM.view.window.product.AddEditCoupon',{
edit: true,
product_restriction: rec.data.product_restriction,
couponOid: rec.data.oid
});
window.down('form').loadRecord(rec);
break;
}
}


My view have radiogroup:


{
xtype: 'radiogroup',
labelWidth: 80,
width: 256,
columns: [100, 100],
fieldLabel: lang.discountKind.capitalize( ),
allowBlank: false,
defaults: {
name: 'rate_type'
},
items:
[{
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.
example:


defaults: {
name: 'rate_type' + recordId
}


Sorry form my bad english.

mitchellsimoens
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.

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



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

mitchellsimoens
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.

dmN86
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.

debabrata
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.

debabrata
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() {
this.callParent(arguments);
}


But setValue() or getValue() function of displayField is not working.
Code is
var form = this.getView('developer.Viewdata');
form.prototype.items[1].setValue('anything');

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

Thanks in advance

mitchellsimoens
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.

dmN86
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.