combo 添加listeners,使用 initComponent、constructor 的区别
2011-08-09 11:48
351 查看
LocationCombo = Ext.extend(Ext.form.ComboBox,{
initComponent: function(){
var config = {
name: 'loactionCombo'
,hiddenName: 'loactionCombo'
,fieldLabel: '所在区域'
,store: [['-1','请选择...']]
,triggerAction: 'all'
,mode: 'local'
,autoScroll: true
,expandPanel : new LocationTree()
,listeners: {
'expand': function(){
alert('expand...');
// if(!combo.expanded){
// combo.expandPanel.render(combo.el);
// combo.doLayout();
// combo.expanded = true;
// //applyToMarkup
// }
}
,'collapse': function(){
alert('collapse');
//document.getElementById('tree').innerHTML='';
}
}
}
this.addListener('expand',function(){alert('2expand..')});
Ext.apply(this, config);
LocationCombo.superclass.initComponent.call(this);
}
});
使用initComponent时,在config对象中写listeners无效,需使用方法添加。而使用constructor则支持 在config对象中写listeners,但ext.2.0不支持constructor.
initComponent: function(){
var config = {
name: 'loactionCombo'
,hiddenName: 'loactionCombo'
,fieldLabel: '所在区域'
,store: [['-1','请选择...']]
,triggerAction: 'all'
,mode: 'local'
,autoScroll: true
,expandPanel : new LocationTree()
,listeners: {
'expand': function(){
alert('expand...');
// if(!combo.expanded){
// combo.expandPanel.render(combo.el);
// combo.doLayout();
// combo.expanded = true;
// //applyToMarkup
// }
}
,'collapse': function(){
alert('collapse');
//document.getElementById('tree').innerHTML='';
}
}
}
this.addListener('expand',function(){alert('2expand..')});
Ext.apply(this, config);
LocationCombo.superclass.initComponent.call(this);
}
});
使用initComponent时,在config对象中写listeners无效,需使用方法添加。而使用constructor则支持 在config对象中写listeners,但ext.2.0不支持constructor.
相关文章推荐
- ExtJS4中initComponent和constructor的区别
- [Ext JS 4] Extjs 之 initComponent 和 constructor的区别
- [Ext JS 4] Extjs 之 initComponent 和 constructor的区别
- ExtJS4中initComponent和constructor的区别
- Android 两种为自定义控件添加属性的使用方法和区别
- Angular中Constructor 和 ngOnInit 的本质区别
- webgrid的使用:(二)、动态的添加webcombo到webgrid上的操作
- unity里使用AddComponentMenu添加自定义组件的一个隐藏坑
- Yii2 使用json 和设置component 中'format' => yii\web\Response::FORMAT_JSON 的区别
- Spring注解的使用和区别:@Component、@Service、@Repository、@Controller
- Spring注解的使用和区别:@Component、@Service、@Repository、@Controller
- 使用.添加属性和使用setattribute的区别
- WinForm中Component Class、User Control及Custom Control的区别和使用
- 说说Android 两种为自定义组件添加属性的使用方法和区别
- JavaScript decodeURI()与decodeURIComponent() 使用与区别
- ngOnInit与constructor的区别
- Page_Load Page_Init方法使用原理 Page 添加 事件