admin管理员组文章数量:1278979
I've created Ext.Window with some Ext.form fields inside. But when I resize window form elements still have initial width and height.
Is it required explicitly resize form fields on window resize? Or there is some option that enables auto resize of form fields?
Sample code:
var f_1 = new Ext.form.TextField({fieldLabel: 'Label 1'});
var f_2 = new Ext.form.TextField({fieldLabel: 'Label 2'});
var fp = new Ext.form.FormPanel({items: [f_1, f_2]});
var w = new Ext.Window({
layout: 'form',
title: 'test',
items: fp
});
w.show()
I've created Ext.Window with some Ext.form fields inside. But when I resize window form elements still have initial width and height.
Is it required explicitly resize form fields on window resize? Or there is some option that enables auto resize of form fields?
Sample code:
var f_1 = new Ext.form.TextField({fieldLabel: 'Label 1'});
var f_2 = new Ext.form.TextField({fieldLabel: 'Label 2'});
var fp = new Ext.form.FormPanel({items: [f_1, f_2]});
var w = new Ext.Window({
layout: 'form',
title: 'test',
items: fp
});
w.show()
Share
Improve this question
asked Nov 11, 2009 at 6:01
Sergey StolyarovSergey Stolyarov
2,6673 gold badges29 silver badges41 bronze badges
3 Answers
Reset to default 4You could check out anchoring, which makes for nicely-resizable forms:
http://www.extjs./deploy/dev/examples/form/anchoring.html
See the "anchor" property on "Component":
http://www.extjs./deploy/dev/docs/?class=Ext.Component
var f_1 = new Ext.form.TextField({fieldLabel: 'Label 1', anchor:'95%'});
would do it. you can see some samples there and the documentation there.
Also if you don't want to specify size for each of them you can push the default from the form panel with the defaults
config object
var fp = new Ext.form.FormPanel({
items: [f_1, f_2]
,defaults: {
anchor: '95%'
}
});
My suspicion is that the FormPanel "fp" is partially at fault.
In Ext JS, it is usually best practice to declare everything from the window all the way down inside the Ext.Window constructor. Creating things and trying to attach them later has been the source of much frustration for me.
(Ok, the other answer about width: 100% is likely better. But still, I've had a lot of problems with resizing, etc. when not declaring everything at once... haven't figured out exactly when it's ok to do so yet.)
本文标签: javascriptExtJS Automatically resize form fields on window resizeStack Overflow
版权声明:本文标题:javascript - ExtJS: Automatically resize form fields on window resize - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741225561a2361791.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论