MyExtra.window.UpdateSubscriber = function(config) {
config = config || {};
Ext.onReady(function() {
var catExtFieldArray = new Array();
var catExtFieldStore = new Ext.data.JsonStore({
url: MyExtra.config.connectorUrl
,baseParams: {
action: 'mgr/subscribers/getCatList'
}
,root: 'results'
,fields: ['id','name']
,autoLoad: false
,listeners: {
'load': {
fn: function(t, records, options) {
for (var n=0; n<records.length; n++) {
catExtFieldArray.push({
name: "newslettercategories[]",
inputValue: records[n].data.id,
boxLabel: records[n].data.name
});
}
}
}
,'loadexception': {
fn: function(obj, options, response, e){
console.info('store loadexception, arguments:', arguments);
console.info('error = ', e);
},scope:this
}
}
});
catExtFieldStore.load();
});
Ext.applyIf(config,{
title: _('myextra.subscriber_update')
,url: MyExtra.config.connectorUrl
,baseParams: {
action: 'mgr/subscribers/update'
}
,fields: [{
xtype: 'hidden'
,name: 'id'
},{
xtype: 'displayfield'
,fieldLabel: _('myextra.subscriber_username')
,name: 'username'
,anchor: '100%'
},{
xtype: 'textfield'
,fieldLabel: _('myextra.subscriber_fullname')
,name: 'fullname'
,anchor: '100%'
},{
xtype: 'textfield'
,fieldLabel: _('myextra.subscriber_email')
,name: 'email'
,anchor: '100%'
},{
xtype: 'checkboxgroup'
,fieldLabel: _('myextra.subscriber_categories')
,columns: 2
,items: catExtFieldArray
}]
});
MyExtra.window.UpdateSubscriber.superclass.constructor.call(this,config);
};
Ext.extend(MyExtra.window.UpdateSubscriber,MODx.Window);
Ext.reg('myextra-window-subscriber-update',MyExtra.window.UpdateSubscriber);
This question has been answered by gadgetto. See the first response.
This is strange. Your code should work.
So, gadgetto, where was the bug?
function catCheckboxGroup(renderTarget,groupName) {
Ext.onReady(function() {
var catStore = new Ext.data.JsonStore({
url: GoodNews.config.connectorUrl
,baseParams: {
action: 'mgr/category/getList'
}
,fields: ['id','name','uniquekey']
,root: 'results'
,autoLoad: false
,autoDestroy: true
,listeners: {
'load': {
fn: function(t, records, options, success) {
var catArray = new Array();
for (var i=0; i<records.length; i++) {
catArray.push({
name: groupName+'['+records[i].data.uniquekey+']'
,inputValue: records[i].data.id
,boxLabel: records[i].data.name
,anchor: '.45'
});
}
var catCheckboxGroup = new Ext.form.CheckboxGroup({
items: catArray
,columns: 2
,renderTo: renderTarget
});
//console.log(catArray);
}
}
/*,'loadexception': {
fn: function(obj, options, response, e){
console.info('store loadexception, arguments:', arguments);
console.info('error = ', e);
}
}*/
}
});
catStore.load();
});
};
...
,{
id: 'cat-ext-checkboxgroup'
,fieldLabel: _('myextra.subscriber_categories')
,anchor: '100%'
,listeners: {
'render': {fn: function() {catCheckboxGroup('cat-ext-checkboxgroup','newslettercategories')}
}
}
...
By the way, don't use Array constructor. Use var catExtFieldArray = [];
If you like array constructor, of course you can use it. See the discussion here, for example.