最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
Extjs NumberField后加单位实现思路
时间:2026-06-09 10:11:59 编辑:袖梨 来源:一聚教程网

=======================
复制代码 代码如下:
// 输入框textfield后面放字unitText定义:
Ext.override(Ext.form.TextField, {
unitText : '',
onRender : function(ct, position) {
Ext.form.TextField.superclass.onRender.call(this,ct, position);
if (this.unitText != ''){
this.unitEl =ct.createChild({
tag: 'div',
html: this.unitText this.unitEl.addClass('x-form-unit'); this.width =this.width
-(this.unitText.replace(/[^x00-xff]/g, "xx").length * 6 +2); this.alignErrorIcon= function() {
this.errorIcon.alignTo(this.unitEl,'tl-tr', [2, 0]); }});
将UnitText.js放入到jsp文件中,加上css样式,如下:
复制代码 代码如下:
<style>
.x-form-unit{
height:22px;
line-height:22px;
padding-left:2px;
display:inline-block;
display:inline; </style>
<script type="text/javascript"src="UnitText.js"></script>
这样就可以用了,使用方法如下:
复制代码 代码如下:
var jine = new Ext.form.NumberField({
id: 'je',
fieldLabel: '金额',
allowDecimals: true, // 允许小数点?
allowNegative: false, // 允许负数?
width: 100,
style: 'text-align:right',
unitText: ' 元'
});
相关文章
- 萝卜快跑运营城市名单 - 2026年最新覆盖城市查询 06-12
- 小笼包的正宗做法与技巧 - 家庭版鲜香多汁小笼包制作指南 06-12
- 双十一广告语大全 - 2026热门创意文案参考 06-12
- 夸克电脑版下载安装 - 官方最新PC客户端 06-12
- ChatGPT引发的社会焦虑现象 - 2026年深度解析 06-12
- 网红城市有哪些 - 2026热门旅游打卡地推荐 06-12