ext中fieldLabel文本太宽的问题,以及Panel居中显示

在layout: ‘column’,后的排列中,右对齐fieldLabel的宽度就不怎么好使。

经过几次调试,终于可以右对齐fieldLabel了,fieldLabel的右对齐比较麻烦,必须首先在form中设置 labelWidth:40,同时在labelStyle中加上labelStyle : “text-align:right;40;”,这2个地方都要设置宽度才行,否则fieldLabel的宽度就不起作用。

{
columnWidth:.33,
layout:’form’,
border:false,
labelWidth: 40,
items:[{
xtype:"combo",
fieldLabel: '地区',
name: 'combo',
labelStyle: 'text-align:right;40;',
store: new Ext.data.SimpleStore({
fields: ['value', 'text'],
data: [
['value1', 'text1'],
['value2', 'text2']
]
}),
displayField: ‘text’,
valueField: ‘value’,
mode: ‘local’,
emptyText:’请选择’
}]
}

用formPanel做了个登录界面,不能在页面居中,以下是解决方法
var panel =new Ext.panel({

});
var windowWidth = window.screen.availWidth;
var left=windowWidth/2 – panel的宽度/2;
var style=’margin-top:150px;margin-left:’+left+’px;’;
var el=Ext.get(‘div-id’).applyStyles(style);
panel .render(el);

可直接用 panel.el.center();//使的PANEL页面居中,注意被渲染之后

原文地址:https://www.cnblogs.com/soundcode/p/2300388.html