如何更改 extjs 中可浮动表单的位置
How can i change the position of floatable form in extjs
我有 ExtJS 形式,它floating
现在我想给%
保证金from top and left
但它不起作用。
示例在这里:
https://fiddle.sencha.com/#fiddle/1dj
var f = new Ext.form.Panel({
width: 400,
height: 400,
title: 'Foo',
floating: true,
closable : true,
y: '10%',
x: '10%',
});
f.show();
尝试以下大小:
var leftPercent=10;
var rightPercent=10;
// Create a viewport, this automatically scales to the window height/width so is predictable in its size
var viewport=Ext.create('Ext.container.Viewport', {
items:[
f
],
listeners:{
resize:function(){
// if the form has been added to the viewport, change its position
f && f.setPosition(viewport.getWidth()*(rightPercent/100), viewport.getHeight()*(rightPercent/100));
}
}
});
var f = new Ext.form.Panel({
width: 400,
height: 400,
title: 'Foo',
autoShow:true,
floating: true,
// set the initial position of the form (not necessarily needed)
x:viewport.getWidth()*(rightPercent/100),
y:viewport.getHeight()*(rightPercent/100)
});
它应该为您提供一个不错的改进/编辑基础。重要的是:
窗口放置在已知的组件/元素中(例如上面的视口)
父容器的高度/宽度在用户与视图交互期间的行为与预测的一样
对父容器的高度宽度的任何更改,然后导致子容器相应地重新定位自身
您可以使用setPosition()
函数更改 Ext.form.Panel 的位置。
例如:-
var f = new Ext.form.Panel({
width: 400,
height: 400,
title: 'Foo',
floating: true,
closable : true,
y: '10%',
x: '10%',
});
f.show();
f.setPosition(100, 200, true);
请参考下面的代码。
配置:
区域 -> 定义内部区域
填充 -> 指定此组件的填充
var f = new Ext.form.Panel({
width: 400,
height: 400,
title: 'Foo',
floating: true,
closable : true,
//padding : '10 0 0 20', // example: '10 0 0 20' (top, right, bottom, left).
region : 'center' // possible values north, south, east, west, and center
});
f.show();
注意:填充用于较小的变化。
第二次尝试:
var f = new Ext.form.Panel({
width: 400,
height: 400,
title: 'Foo',
floating: true,
closable : true,
left : 10,
top : 10
});
f.show();
相关文章:
- 当选择值x时,Javascript需要在正确的位置显示文本区域,从而循环通过具有选择选项的表单
- 如何在提交html表单后保持相同的位置
- HTML 按钮以在页面上的其他位置提交表单
- 如何将HTML表单提交到2个位置=Java脚本和PHP
- 当用户使用jquery点击任何位置时,切换并隐藏登录表单
- 为多个表单动态指定输出ajax成功结果的位置
- 谷歌表单:在文档的电子邮件中包含超链接'谷歌硬盘的位置
- 在表单中提交用户位置
- EXT-JS 4.2.1 保留表单 - 面板滚动条的当前位置
- 使用 Jquery 在鼠标单击时反转表单元素的位置
- 如何更改 extjs 中可浮动表单的位置
- 使 iframe/表单固定位置
- 使用地理位置自动填写地址表单
- 将显示与位置绝对输出移动的表单放入移动模式引导按钮中
- 获取表单元素的大小和位置
- 使用 AJAX 将表单提交到两个位置
- 延迟表单提交,直到检索到位置
- 使用 PHP 或 JavaScript 解析 pdf 表单以获取字段位置
- 在回发(提交)时保持表单位置 asp.net MVC
- 带有可变表单位置的Ajax URL