PDA

View Full Version : Use a store to create a RadioGroup



jason.hutton
14 Dec 2010, 11:40 AM
Does any one have an example of taking JSON and creating a RadioGroup?

Thanks in advance
Jason Hutton

jason.hutton
14 Dec 2010, 2:35 PM
Got this to work.

The Direct Store:

Application.Data.RoleStore = new Ext.data.DirectStore({
paramsAsHash: false,
root: 'ROWS',
totalProperty:'DATASET',
autoLoad:true,
directFn: Application.Data.ss['icefyre.com.objects.RoleService'].getAllRoles,
fields: [
{name:'Role_ID',type:'int'},
{name:'Role',type:'string'}
],
listeners: {
load:{
fn: function(st,recs,opts)
{
var rGroup = Ext.getCmp('RoleFieldGroup');
rGroup.items.length = 0;
Ext.each(recs, function(item)
{
checked = false;
if(item.data.Role_ID === 3)
checked = true
rGroup.items.push({
xtype: 'radio',
boxLabel: item.data.Role,
inputValue: item.data.Role_ID,
name: 'RoleField',
checked: checked
});
});
rGroup.doLayout();
}
},
loadexception: {
fn: function()
{
}
}

}
})

The RadioGroup in my FormPanel:

{
xtype: 'radiogroup',
fieldLabel: 'Role',
id:'RoleFieldGroup',
columns: 1,
items: [
{boxLabel: 'Standard User', name: 'RoleField', inputValue:'1', checked: true}
]
}

Hope that helps someone else. If there is a way to do it better let me know.

Thanks