PDA

View Full Version : How can I Remote Loading Items use extjs 4 checkbox group



ddsbn
1 Apr 2012, 9:56 PM
my code


Ext.define('Ehr.abstract.CheckboxGroup', {
extend : 'Ext.form.CheckboxGroup',
alias : 'widget.selectcheckboxgroup',
initComponent : function() {
var me = this;
me.items = [];
me.store = Ext.create('Ext.data.Store', {
model : 'Ehr.model.Selectoption',
proxy : {
type : 'ajax',
url : 'selectoption/getSelectOption.action?name='
+ me.nameparam,

reader : {
type : 'json',
root : 'data'
}
}
});
me.store.load(function(records, operation, success) {
Ext.each(records,function(record){
var item = Ext.create('Ext.form.field.Checkbox',{
boxLabel : record.data.itemLabel,
inputValue: record.data.itemValue,
name : me.id
});
me.add(item);

});
me.doLayout();
});
me.callParent(arguments);
}
});

scottmartin
9 Apr 2012, 10:53 AM
You should make the ajax call to get your items, then create your object, not try to gather your items from the server while you are creating. Ajax is taking to long and your code has already moved on.

Ext.Ajax.request({
url: ...
success: function(xhr) {
// create checkboxgroup with items
var json = Ext.decode(xhr.responseText); // json.data to get item data
}
});

Regards,
Scott