Home > Web Front-end > JS Tutorial > Implementation idea of ​​adding unit after Extjs NumberField_extjs

Implementation idea of ​​adding unit after Extjs NumberField_extjs

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:27:53
Original
1440 people have browsed it

UnitText.js
=======================

Copy code The code is as follows:

// Put the word unitText after the input box textfield definition:
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 css style, as follows:
Copy code The code is as follows:




This way you can use it. The usage method is as follows:
Copy code The code is as follows:

var jine = new Ext.form.NumberField({
id: 'je' ,
fieldLabel: 'Amount',
allowDecimals: true, // Allow decimal points?
allowNegative: false, // Allow negative numbers?
width: 100,
style: 'text-align:right',
unitText: '元'
});
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template