the singularity of being and nothingness
ExtJS Quickie: Full Width Text Fields
Ok, so a lot of posts I make are not so much about “hey, look at this cool thing I figured out” as much as it is saving a reminder of myself for how to do something when I inevitably forget it later on 🙂
So for today’s example, the problem I was having was how to make a textfield fill up 100% width of a panel. I think in earlier versions of ExtJS, there was an “autoWidth” option, but alas, it doesn’t work in ExtJS 4. Moreover, using “width: ‘100%'” doesn’t work either, since the width option expects a numeric value.
Turns out, this is pretty stupid and simple. Here’s a quick example:
Ext.define("Gloss.view.search.Form", { extend: "Ext.form.Panel", alias: "widget.searchform", frame: true, items: [ { xtype: "textfield", anchor: "100%" } ], initComponent: function() { this.callParent(arguments); } });
As you can see, adding in the “anchor: 100%” solves the issue quite nicely. Now, as the container is resized, the textfield will resize as well.
Print article | This entry was posted by existdissolve on July 17, 2011 at 5:39 am, and is filed under ExtJS. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |
about 10 years ago
So, what is the solution when you have a fieldLabel?
{
xtype: ‘textfield’,
fieldLabel: ‘Name this alert’,
name: ‘triggerName’,
anchor: “100%”,
allowBlank: false,
}
Does not work in 4.2.2
about 10 years ago
Can you show your code for the container around the textfield? I created a Fiddle (https://fiddle.sencha.com/#fiddle/a3j) for 4.2.1, which works identically in 5.0.x. Unfortunately, Fiddle doesn’t have 4.2.2, so maybe a bug if it’s not working in that?
But share your code anyway and I’ll be happy to try to help diagnose.
Thanks!