PDA

View Full Version : getTextWidth to work for CompositeElement.


Animal
12-12-2008, 05:05 AM
This would add a very useful way of measuring the width of a whole bunch of elements using DomQuery.

Calculating the max width of the composite:


Ext.override(Ext.CompositeElement, {
getTextWidth: function() {
var i, e, els = this.elements, result = 0;
for(i = 0; e = Ext.get(els[i]); i++) {
result = Math.max(result, e.getTextWidth.apply(e, arguments));
}
return result;
}
});

Animal
12-12-2008, 05:10 AM
With an eye to the requested, sophisticated doAutoWidth method: http://extjs.com/forum/showthread.php?p=217066#post217066

Animal
12-12-2008, 07:06 AM
This'd help with autosizing form labels. It's a bit annoying that you have to hardcode them. Of course, you need to set the padding on each x-form-element as well as the width of the label...