PDA

View Full Version : generate a radiogroup from a JsonStore



cegelec02
1 Dec 2011, 8:18 AM
Hi everyone,

I'm trying to generate a radiogroup from a JsonStore.

this is my Json Store :


var ds = new Ext.data.JsonStore({
proxy : new Ext.data.HttpProxy({
method: 'POST',
timeout:500000,
prettyUrls: false,
url: '<%=contextPath%>/choixProfil/chargerChoix.action'
}),
root: 'data',
totalProperty: 'count',
fields: [{name: 'profil_id', type: 'int'},
{name: 'profil', type: 'string'},
],
writer: new Ext.data.JsonWriter(),
autoSave: false,
remoteSort: false
});



and this is my container and my radiogroup :



conteneurPrincipal = new Ext.Container({
id:'formPrincipal',
xtype: 'container',
height: 250,
width: 692,
items: [
{
xtype: 'radiogroup',
fieldLabel: 'Profil',
id:'ProfilFieldGroup',
columns: 1,
items: [{
boxLabel: 'boxLabel',
inputValue: '0',
name: 'name',
checked: false
}]
}
],
renderTo: Ext.getBody()
});



when my JsonStore is loaded, the radiogroup is modified :


ds.on('load', function(store, records, options)
{
var rGroup = Ext.getCmp('ProfilFieldGroup');
rGroup.items.clear();
ds.each(function(record)
{
rGroup.items.items.push(
new Ext.form.Radio({
boxLabel: record.data.profil,
inputValue: record.data.profil_id,
name: 'ProfilField',
checked: false
})
);
}, this);
conteneurPrincipal.doLayout();
});


firebug shows that the rGroup has been modified and the radiogroup in conteneurPrincipal too but the doLayout has no effect.

any advice please ?

mitchellsimoens
1 Dec 2011, 12:21 PM
You will need to remove the radiogroup, build the items array and add a new radiogroup.

cegelec02
2 Dec 2011, 2:36 AM
Thank you !