PDA

View Full Version : Add items dynamically to card layout



stefano
11 Apr 2013, 7:03 AM
I have a card layout with no items:


Ext.define('AM.view.applications.FunctionWindow', {
extend: 'Ext.window.Window',
title: 'Example Wizard',
width: 300,
height: 200,
layout: 'card',
items: []
});


I need to create dynamically some panels and add them to layout as cards.
I tried adding the following code to initComponent function, but I have an error:


var p0 = Ext.create('Ext.panel.Panel', {
id: 'card-0',
title: 'Hello',
width: 200,
html: '<p>World!</p>'
});
this.add(p0); // -----> ERROR
// this.items.add(p0); // --------> ERROR


The error is:
TypeError: me.items.insert is not a function

Where is the problem?
How can I add a panel dynamically to card layout?

Thank you
bye
stefano

girish.arjunagi
11 Apr 2013, 9:02 AM
stefano,
It seems you are not doing this.callParent(arguments) in the initComponent function. Please try with the below code.



initComponent : function(){
this.callParent(arguments);
var p0 = Ext.create('Ext.panel.Panel', {
id: 'card-0',
title: 'Hello',
width: 200,
html: '<p>World!</p>'
});
this.add(p0);
}