-
4 Dec 2012 7:50 AM #1
Unanswered: Changing the Panel Header Title on an Event
Unanswered: Changing the Panel Header Title on an Event
Hi,
I have a panel which is updated on another grid's row double click. Everything changes except for the title of the panel. Here is the code:
The error: 'Cannot call method 'setTitle' of undefined'.Code:listeners : { itemdblclick: function(dv, record, item, index, e) { Ext.getCmp('panel1').setTitle('Title changed'); //this does not work } }
What am I missing here?
'panel1' is defined in another .js file where I have also defined 'panel1' as a global variable in the .js file. The code is:
Code:var panel1= Ext.create('Ext.panel.Panel',{ autoshow : true, id: 'panel1', name: 'panel1', renderTo : 'panelview', layout : 'border', height: 400, title: 'CANT CHANGE THE TITLE', items : [{ xtype: 'panel', align: 'stretch', region:'center', ........ }] });
-
4 Dec 2012 9:04 AM #2
For some reason the component manager cant find the component with id 'panel1'. If you do such queries always wrap it with a if(), it may fail updating the tile but at least the app will continue to work.
You have defined the renderTo property, it may overrides the origin id and becomes panelview.
-
4 Dec 2012 10:45 AM #3
But how do I integrate the code to update the title of my panel header on dblclick event?
-
4 Dec 2012 10:47 AM #4
try it with Ext.getCmp('panelview') instead.
Keep in mind: working with ids is a bad approach, it will getting fuzzy when the project grows. You may want to re-think your layout logic and check out the component query in the docs.
-
4 Dec 2012 10:56 AM #5
The error does not come anymore but the title does not change either. I have used : Ext.getCmp('panelview').setTitle('Title changed'); instead of Ext.getCmp('panel1').setTitle('Title changed');
I dblclick on one of the grid rows of the other grid panel but the title of this panel does not change.
-
4 Dec 2012 10:59 AM #6
please try:
console.log(Ext.getCmp('panelview'));
console.log(Ext.getCmp('panel1'));
and check if you get the right panel component.
If not, it must be some other issue.
-
4 Dec 2012 11:20 AM #7
I checked that and I am getting some dom null error.
-
4 Dec 2012 11:36 AM #8
I got this working. It seems that I was allocating the wrong global variable. Thanks for the help.



Reply With Quote