ExtJs form界面显示之界面调整(游览器兼容性)

ExtJS的界面不咋好看,但是兼容性还不错。下面要介绍一个ExtJS由于编程而引起的游览器兼容性问题。

[b][color=green]火狐下formPanel界面[/color][/b]
[img]http://dl.iteye.com/upload/attachment/527894/07dc2d2c-ca86-3910-ba75-9a1f7ecad7c5.bmp[/img]

[b][color=red]IE下formPanel界面[/color][/b]
[img]http://dl.iteye.com/upload/attachment/527909/2639a379-7954-3b77-828e-7b907ab2727b.bmp[/img]

[b]ExtJS的formPanel中元素的代码:[/b]

/*端口**/
defPortField = new Ext.form.NumberField({
fieldLabel: 'FTP端口',
width : 160,
labelSeparator:'',
id:'defPortField',
allowBlank : false,
allowNegative : false,
allowDecimals : false
});

ftpUserField = new Ext.form.TextField({
defaultType : 'textfield',
width : 160,
labelSeparator:'',
id:'ftpUserField',
fieldLabel : '用户',
allowBlank : false
});

ftpUserPassField = new Ext.form.TextField({
defaultType : 'textfield',
width : 160,
labelSeparator:'',
id:'ftpUserPassField',
fieldLabel : '密码',
allowBlank : false
});

ftpRootPathField = new Ext.form.TextField({
defaultType : 'textfield',
width : 160,
labelSeparator:'',
id:'ftpRootPathField',
fieldLabel : 'FTP根目录',
allowBlank : false,
regex : /^\/[^\\]*$/,
regexText : '根目录格式不正确'
});


[color=red][b]问题代码[/b][/color]

var ftpServSetForm = new Ext.FormPanel({
width:330,
frame: true,
layout: 'column',
items: [{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [ftpHostField]
},{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [defPortField]
},{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [ftpUserField]
},{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [ftpUserPassField]
},{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [ftpRootPathField]
}]
});

[color=green][b]
正确显示的代码[/b][/color]

var ftpServSetForm = new Ext.form.FormPanel({
id : 'tool_ftpServSetForm',
width:330,
layout: 'column',
frame: true,
items: [{
columnWidth : .99,
xtype: 'fieldset',
labelWidth: 140,
defaultType: 'textfield',
autoHeight: true,
border: false,
items: [ftpHostField, defPortField, ftpUserField,
ftpUserPassField, ftpRootPathField]
}]
});


分析:问题代码中,将每个form都分开到一个“fieldSet”中显示,相当于有5个“fieldSet”,在IE下显示就会相隔很远的距离,布局的时候容易把距离弄乱掉。
而火狐并不分别这个类型问题,布局正常。

正确的应该是将各个field放到一个“fieldSet”下,这样各个浏览器都能正常浏览。

[b]总结: 这只是个很小的问题,编程习惯好的人根本不会遇到。弄清楚这个问题,让我在以后写代码的时候可以不再犯同样的问题,这就是进步了。
[/b]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值