PDA

View Full Version : [1.0.1a / 1.1b1] Suggestion: Preserve pre-transform width of Ext.form.Fields



mystix
7 Jun 2007, 6:59 AM
Hi jack,

in both 1.0.1a and 1.1 beta 1, the pre-transformation width of HTML elements is not preserved in the Ext.form.Field transformation process.

here's my drop-in test code for 1.1b1:
<html>
<head>
<title>Pre / Post-transform width</title>
<link rel='stylesheet' href='resources/css/ext-all.css'>
<script src='adapter/ext/ext-base.js'></script>
<script src='ext-all-debug.js'></script>

<script>
Ext.onReady(function() {
(new Ext.form.DateField()).applyTo('test');
});
</script>
</head>
<body>
<input type='text' id='dummy' size='100'/>
<input type='text' id='test' size='100'/>
</body>
</html>
imho, i thought it would be good if the post- and pre-transform widths were the same to prevent positioned elements from running amok after Field transformations.


for now, here's my somewhat ugly suggestion (tested in 1.0.1a and 1.1b1):
Ext.override(Ext.form.Field, {
applyTo : function(target) {
this.target = target;
this.el = Ext.get(target);
this.width = this.width || this.el.getWidth(); // store pre-transform width before rendering
this.render(this.el.dom.parentNode);
return this;
}
});to preserve the pre-transform width.

Could something like this be added to the trunk?

jack.slocum
7 Jun 2007, 10:12 PM
What does this help exactly?

mystix
7 Jun 2007, 11:53 PM
When transforming already positioned markup into Ext.form.Fields, it would be helpful if the transformed elements don't get shrunk width-wise so the existing page layout is (more or less) preserved (assuming that existing markup does not contain consecutive adjacent <input> fields like so:
<input type='text' id='testDateField'/><input type='text' id='testTextField'/>)

I was toying with having transformed elements' wrapper <div>s displayed inline (instead of the default display:block) to eliminate the need for custom css to compensate for elements being moved around post-transformation.

would you advise against even trying to do this?