Threaded View
-
13 Jul 2010 5:42 AM #1
[CLOSED] Ext.Element -> getWidth + fix
[CLOSED] Ext.Element -> getWidth + fix
hi team,
this might be the biggest bugfix i posted so far, since it will resolve quite a bunch of issues.
in the past i had several problems with rendering hidden items and width calculations, most were tabbed forms with deferredRender: false.
+ i had comboBoxes that were 17px (the width of the trigger) to wide
+ errorIcons displayed over the fieldLabel
+ sliders with the thumb always at zero
and many more issues. this all went down to the point, that the width-calculations returned 0 if rendered hidden. i used hideMode: offsets quite a lot because of this. the solution i found also works with the default display-mode.
so, here it is:
i had to write "Math" instead of "MATH", since i can not access the attribute with an override.Code:Ext.override(Ext.Element, { getWidth : function(contentWidth){ var me = this, dom = me.dom, hidden = Ext.isIE && me.isStyle('display', 'none'), w = Math.max(dom.offsetWidth || parseInt(dom.style.width, 10), hidden ? 0 : dom.clientWidth) || 0; w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr"); return w < 0 ? 0 : w; } });
here is a small usecase, showing my sliderField usecase with normal hideMode:display.
tested in ff3.6, ie8 and chrome. the fix for getHeight should work the same way.
Code:Ext.onReady(function(){ Ext.override(Ext.Element, { getWidth : function(contentWidth){ var me = this, dom = me.dom, hidden = Ext.isIE && me.isStyle('display', 'none'), w = Math.max(dom.offsetWidth || parseInt(dom.style.width, 10), hidden ? 0 : dom.clientWidth) || 0; w = !contentWidth ? w : w - me.getBorderWidth("lr") - me.getPadding("lr"); return w < 0 ? 0 : w; } }); new Ext.form.FormPanel({ renderTo: document.body, width:600, height:250, layout:'fit', border:false, labelWidth : 100, items : [{ xtype: 'tabpanel', activeTab: 0, deferredRender: false, layoutOnTabChange: true, plain:true, defaults:{autoScroll: true}, items:[{ title: 'Tab 1', html: "My content was added during construction." },{ title: 'Tab 2', layout: 'form', items: [{ fieldLabel: 'Sliderfield', maxValue : 500, minValue : 0, value : 250, width : 200, xtype : 'sliderfield' }] } ] }] }); });
kind regards,
tobiu
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
[CLOSED]An Ext.grid.GridPanel.processEvent fix proposal
By Dmitry Ovsyanko in forum Ext 3.x: BugsReplies: 1Last Post: 10 Mar 2010, 7:01 AM -
[CLOSED][3.??] Bug + fix for Ext.ListView and IE6
By mvt in forum Ext 3.x: BugsReplies: 3Last Post: 16 Aug 2009, 12:18 PM -
[CLOSED][3.0.0] Event handler arguments receive DOM element instead of Ext.Element
By jherfurth in forum Ext 3.x: BugsReplies: 6Last Post: 18 Jul 2009, 12:30 PM -
[2.0][CLOSED] Ext.get/Ext.getDom does not fix IE's document.getElementById bug
By noelito in forum Ext 2.x: BugsReplies: 1Last Post: 14 Apr 2008, 11:11 AM -
getWidth method in YAHOO.ext.Element
By jclawson in forum Ext 1.x: BugsReplies: 6Last Post: 4 Mar 2007, 11:52 PM


Reply With Quote