Javascript-форум (https://javascript.ru/forum/)
-   ExtJS (https://javascript.ru/forum/extjs/)
-   -   Помогите с наследованием (https://javascript.ru/forum/extjs/10472-pomogite-s-nasledovaniem.html)

serega063 06.07.2010 16:19

Помогите с наследованием
 
Есть базовый класс.
Ext.ns('Application');
Application.Dt_area = Ext.extend(Ext.Toolbar, {
	id: 'dt',
	height: 27,
	visibleEdt:true,
	initComponent:function() {
		Ext.apply(this, {
			items: [{
					xtype: 'button',
					text: 'Показать',
					scope:this,
					handler: function(){this.onShowClick()}
					}]
		})
		Application.Dt_area.superclass.initComponent.apply(this, arguments);
		} ,onRender:function() {
		Application.Dt_area.superclass.onRender.apply(this, arguments);
		/*for(var i=0;i<arguments.length;i++) {
		 alert("arguments["+i+"] = "+arguments[i])
		}*/
		} // eo function onRender	
});


Возникла необходимость, добавить несколько кнопок, и изменить текст кнопки у базового класса


Соответственно создаю наследника, но как добавить еще кнопку, и изменить текст кнопки базового класса у меня не получается.
Application.Dt_area_ = Ext.extend(Application.Dt_area, {
	id: 'dt',
	height: 27,
	visibleEdt:true,
	initComponent:function() {
		Ext.apply(this, {
			items: [{
					xtype: 'button',
					text: 'Показать все',
					scope:this,
					handler: function(){this.onShowClick()}
				}]
				})
		          
				Application.Dt_area_.superclass.initComponent.apply(this, arguments);
				} 
	
});


Заранее благодарен

Kolyaj 06.07.2010 16:35

Метод add после вызова initComponent родительского класса.

serega063 06.07.2010 16:38

Вот так?
Application.Dt_area_ = Ext.extend(Application.Dt_area, {
	id: 'dt',
	height: 27,
	visibleEdt:true,
	scope:this,
	initComponent:function() {
		Ext.apply(this, {
			items: [{
				xtype: 'button',
				id:'exc1',
				icon: 'img/excel.png',
				align: 'right',
				handler:  function(){ 
							this.onExpExcel();
						}
				}]
				})
		       this.items.add({
					xtype: 'button',
					id:'exc1',
					icon: 'img/excel.png',
					align: 'right',
					scope:this,
					handler:  function(){ 
								this.onExpExcel();
							}
				});  
				Application.Dt_area_.superclass.initComponent.apply(this, arguments);
				} 
	
});

Тоже не работает((

Kolyaj 06.07.2010 16:43

В вашей вложенности разобраться нереально, поэтому не знаю точно в чём проблема, но по крайней мере
Цитата:

Сообщение от Kolyaj
после вызова initComponent родительского класса.


serega063 07.07.2010 08:20

Все спасибо разобрался.
Может кому поможет
Application.Dt_area_ = Ext.extend(Application.Dt_area, {
	id: 'dt',
	height: 27,
	visibleEdt:true,
	scope:this,
	initComponent:function() {
		       this.add({
					xtype: 'button',
					id:'exc1',
					icon: 'img/excel.png',
					align: 'right',
					scope:this,
					handler:  function(){ 
								this.onExpExcel();
							}
				});  
				Application.Dt_area_.superclass.initComponent.apply(this, arguments);
				} 
	
});


Часовой пояс GMT +3, время: 04:59.