Yes I seemed to solve the problem - extjs is not the easiest area to get to grips with but once you have grasped it it is well worth the effort. I have now developed over 50 CMP pages across a few client projects and the result of having everything seamlessly integrate in the manager is well worth it from an end user/usability perspective.
So the solution I ended up with: first define the two combo boxes:
SFProperties.combo.Sector = function(config) {
config = config || {};
Ext.applyIf(config,{
hiddenName: 'sector'
,displayField: 'sector'
,valueField: 'id'
,fields: ['id', 'sector']
,url: SFProperties.config.connectorUrl
,baseParams: { action: 'mgr/sfsector/getList'}
,editable: false
,lazyInit: false
});
SFProperties.combo.Sector.superclass.constructor.call(this,config);
};
Ext.extend(SFProperties.combo.Sector, MODx.combo.ComboBox);
Ext.reg('combo-sector', SFProperties.combo.Sector);
SFProperties.combo.Subsector = function(config) {
config = config || {};
Ext.applyIf(config,{
hiddenName: 'subsector'
,displayField: 'subsector'
,valueField: 'id'
,fields: ['id','sectorid','subsector']
,url: SFProperties.config.connectorUrl
,baseParams: { action: 'mgr/sfsubsector/getListfiltered' }
,editable: false
,lazyInit: false
});
SFProperties.combo.Subsector.superclass.constructor.call(this,config);
};
Ext.extend(SFProperties.combo.Subsector, MODx.combo.ComboBox);
Ext.reg('combo-subsector', SFProperties.combo.Subsector);
Then, when these are used within the ExtJS form definition, add a couple of in-line listeners:
},{
xtype: 'combo-sector'
,fieldLabel: _('sector')
,name: 'sector'
,id: 'sector'
,listeners:
{
'select': { fn:function(combo, value)
{
var subsectorCmp = Ext.getCmp('subsector');
subsectorCmp.setValue('');
subsectorCmp.setDisabled(false);
subsectorCmp.baseParams['sectorid'] = combo.getValue();
}}
}
,width: 200
},{
xtype: 'combo-subsector'
,id: 'subsector'
,fieldLabel: _('subsector')
,name: 'subsector'
,disabled: true
,listeners:
{
'beforeQuery': { fn:function()
{
delete this.lastQuery;
}}
}
,width: 200
Basically, on select of the sector, it gets a handle to the Ext component that you want to be linked. It sets a BaseParam that is used in the PHP processor file (in this case sectorid; then the 'beforeQuery' method on the second combo box first clears the current query, in effect forcing a refresh of the drop down list, by delete the cached lastQuery.
Hope it helps.
Tim