UnitText. js
======================================
Copy codeThe Code is as follows:
// Define unitText after textfield in the input box:
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]) ;}});
Put UnitText. js into the jsp file and add the css style as follows:
Copy codeThe Code is as follows:
<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>
You can use it as follows:
Copy codeThe Code is as follows:
Var jine = new Ext. form. NumberField ({
Id: 'Je ',
FieldLabel: 'ant ',
AllowDecimals: true, // allow decimal point?
AllowNegative: false, // negative number allowed?
Width: 100,
Style: 'text-align: right ',
UnitText: 'meta'
});