Reputation: 533
I ask many Question, but Anybody no answer me...
please answer this question..
Hi, i'm novice at Extjs4
I use extjs4,
I make one component, like this
var child1 = Ext.create('Ext.form.Panel', {
xtype : 'panel',
title : 'child1',
html : 'child1'
});
and, I use this to Window 1, like this
var win1 = Ext.create('Ext.window.Window', {
title : 'window1',
height : 200,
width : 400,
layout : 'fit',
items : child1
}).show();
and I wanna use 'child1', another window, like this
var win2 = Ext.create('Ext.window.Window', { // setting
height : 200,
width : 200,
layout : 'fit',
title : 'window2',
items : child1
}).show();
but this is wrong Code.
it is just see in Window2.
but I wanna use 'child1' both win1 and win2...
How can i do that?, Thanks!
Upvotes: 0
Views: 324
Reputation: 1310
If you are going to use re-use a component, create a view and assign an alias using widget.*
Ext.define('MyApp.view.Child1', {
extend: 'Ext.panel.Panel',
alias: 'widget.child1',
html: 'child1'
});
Then, when you create your window you can reference by xtype.
var win1 = Ext.create('Ext.window.Window', {
title : 'window1',
height : 200,
width : 400,
layout : 'fit',
items : [{ xtype: 'child1'}]
}).show();
Upvotes: 1
Reputation: 17860
You can use both them just fine. But items is array - so you need to change it to items: [ child1 ]
Upvotes: 0