PDA

View Full Version : How to dynamically add / remove panel tools item ?



deathgod86
31 Jan 2014, 12:45 AM
Hi,

How can I dynamically add / remove panel tools item ?

Info:


OS: Windows 7
Browser: Safari 5.1.7
Running in normal desktop Win7 Safari
ExtJS version: 4.2.1.883


Sample Code:


Ext.define('SampleForm', {
extend: 'Ext.tab.Panel',
xtype: 'SampleForm',

id: 'SampleForm',

tools: [{
xtype: 'button',
text: 'Save'
}],
});


However, when i tried to list the items in tools it is empty.

Sample Code:


console.log(Ext.getCmp('SampleForm').tools);


Result (an empty array):


[]


Thanks in advance.

mdnaveed42
31 Jan 2014, 1:44 AM
Hi,


Ext.create('Ext.panel.Panel', { title: 'Hello',
width: 200,
html: '<p>World!</p>',
id: 'SampleForm',
tools: [{
xtype: 'button',
text: 'Save'
}],
renderTo: Ext.getBody()
});


Ext.ComponentQuery.query('#SampleForm')[0].addTool({
xtype: 'button',
text: 'Cancel'
});

I would suggest you to create the tools before hand and show/hide as per requirement.
For more details on this, please refer http://www.sencha.com/forum/showthread.php?279979

Thanks,
Md Naveed

deathgod86
5 Feb 2014, 8:57 PM
Thanks for your prompt response.

I would like to dynamically add is because what are the availables such as buttons are not known upfront.
I am designing so that it is up to the user to configure (add/remove).

Thanks.