-
6 Oct 2008 10:36 AM #1Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
[2.2.x] Panel.setIconClass breaks for any collapsible panel
[2.2.x] Panel.setIconClass breaks for any collapsible panel
Reproduce:
go to: http://extjs.com/deploy/dev/examples...t/complex.html
observe icons for east, west, south and accordion panels.
paste:
It seems that the setIconClass method is incorrectly placing the img tag before the tool, which should be after.Code:var icon = 'nav'; Ext.getCmp('west-panel').setIconClass(icon); // East panel title bar Ext.getCmp('ext-comp-1017').setIconClass(icon); // East panel title bar Ext.getCmp('ext-comp-1018').setIconClass(icon); // South panel title bar Ext.getCmp('ext-comp-1019').setIconClass(icon); // First accordion
Quick override:
Code:Ext.override(Ext.Panel, { setIconClass : function(cls){ var old = this.iconCls; this.iconCls = cls; if(this.rendered && this.header){ if(this.frame){ this.header.addClass('x-panel-icon'); this.header.replaceClass(old, this.iconCls); } else{ var hd = this.header.dom; var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null; var insertWhere = 'insertBefore'; if (this.collapsible || this.ownerCt.layout == 'accordion') { /* hd.firstChild is the tool icon for collapsing */ if (old) { img = hd.childNodes[1] && String(hd.childNodes[1].tagName).toLowerCase() == 'img' ? hd.childNodes[1] : null; } else { insertWhere = 'insertAfter'; } } if(img){ Ext.fly(img).replaceClass(old, this.iconCls); } else{ Ext.DomHelper[insertWhere](hd.firstChild, { tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+ this.iconCls }); } } } } });
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
13 Oct 2008 6:10 AM #2
That override only works when the panel has a single tool.
This worked better for me:
Code:Ext.override(Ext.Panel, { setIconClass : function(cls){ var old = this.iconCls; this.iconCls = cls; if(this.rendered && this.header){ if(this.frame){ this.header.addClass('x-panel-icon'); this.header.replaceClass(old, this.iconCls); }else{ var img = this.header.child('.x-panel-inline-icon'); if (img) { img.replaceClass(old, this.iconCls); }else{ var tool = this.header.last('.x-tool'); if ( tool ) { Ext.DomHelper.insertAfter(tool, { tag: 'img', src: Ext.BLANK_IMAGE_URL, cls: 'x-panel-inline-icon '+ this.iconCls }); } else { Ext.DomHelper.insertBefore(this.header.dom.firstChild, { tag: 'img', src: Ext.BLANK_IMAGE_URL, cls: 'x-panel-inline-icon '+ this.iconCls }); } } } } } });
-
13 Oct 2008 6:12 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
Awesome. I have yet to construct something with more than one tool


Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
10 Feb 2009 2:44 AM #4
I wonder why they didn't fix this in 2.2.1?
-
14 Oct 2009 4:07 AM #5
*bump*
This is still not fixed in 2.3.0.
Don't know if this is fixed in 3.0.0.


Reply With Quote