PDA

View Full Version : How to render dynamic checkboxgroup on form panel in Ext 3.1?



redds1
27 Feb 2013, 7:33 AM
The code snippet is below. Essentially there is a combo box, the selected value is passed to the query of the checkbox and the data is returned, that's why I am calling the checkbox in the listener of the combo box. It's returning the correct JSON data but the checkbox is not coming up on screen. The error I see is "this.items[0] is undefined". I have tried everything under the sky but it does not seem to work. Please help.


// Checkbox Store

testArray = new Array();

var testStore = new Ext.data.JsonStore({
proxy:new Ext.data.HttpProxy({
method:'GET',
prettyUrls:false,
url:'sdr',
listeners:{
'loadexception':{
fn:test.form.data.loadException
}
}
}),
fields:['id', 'display'],
autoLoad:false,
reader:new Ext.data.JsonReader({
id:'id',
root:'results',
totalProperty:'totalCount',
fields:new Ext.data.Record.create([
{
name:'id',
type:'int'
},

{
name:'display',
type:'string'
}
])
}),
listeners:{
load: function(t, records, options, success) {
for(var i=0; i<records.length; i++) {
testArray.push({
name:records[i].data.id (http://data.id),
boxLabel: records[i].data.display
});
}
}
}
});


//Form Panel


{
xtype:'combo',
id:'comboid',
disabled:false,
fieldLabel:'Combo',
store:combostore,
displayField:'display',
valueField:'id',
tabIndex:1,
listeners :{
select:function(event){
testStore.baseParams = {
"comboid":Ext.getCmp('comboid').getValue()
};

testStore.load();


var myCheckboxgroup = new Ext.form.CheckboxGroup({
id:'checkid',
fieldLabel: 'Checkboxes',
boxLabel:'State',
items:testArray //created in previous
snippet.
});

Ext.getCmp('activateStatenolForm').add(myCheckboxgroup);

Ext.getCmp('activateStatenolForm').doLayout();
}
}

}

mitchellsimoens
1 Mar 2013, 8:12 AM
So when you add the checkboxgroup and execute doLayout it isn't shown? I'm assuming the form panel has id of 'activateStatenolForm'