Reputation: 333
I have a Ext panel and I want to set the Title of the panel from some variable .
I have the id
of the panel and I need to set the title of the panel from it.
I am looking for some thing like this,
Ext.getCmp('myPanel').setTitle();
like atribute
Ext.define('Myapplication.view.Contacts', {
extend: 'Ext.Panel',
alias: 'widget.Contacts',
id: 'myPanelID',
----
-----
------
-----
listeners: [
{
fn: 'initComponent',
event: 'initialize'
}
]
},
initComponent: function(component, options, wstitle) {
Ext.getCmp('myPanelID').header.title = ('Title of panel'); //Not working
Ext.getCmp('myPanelID').setTitle= ('Title of panel'); //Not working
}
alway got an error:
TypeError: 'undefined' is not an object (evaluating 'Ext.getCmp('myPanel').setTitle')
Upvotes: 0
Views: 3901
Reputation: 1388
Ext.Panel
is a instead of Ext.Container
so, is a container and not is an object. If you want change someone like title
you can try something like this,
Ext.define('Myapplication.view.Contacts', {
extend: 'Ext.Panel',
alias: 'widget.Contacts',
id: 'myPanelID',
...
html: '<div>Your Title</div>',
...
initComponent: function(component, options, wstitle) {
Ext.getCmp('myPanelID').setHtml('<div>Another Title</div>');
}
})
Hope these helps. :)
Upvotes: 1
Reputation: 3880
you got a syntax error. You write
Ext.getCmp('myPanelID').setTitle= ('Title of panel'); //Not working
remove the = char
Ext.getCmp('myPanelID').setTitle('Title of panel'); //Works like a charm
cheers, Oleg
Upvotes: 0
Reputation: 5724
Ext.getCmp('myPanelID').setTitle
is a function.
So...
Ext.getCmp('myPanelID').setTitle('Title of panel');
Is what you are looking for
Upvotes: 0