ExtJS 使用点滴 九 FormPanel 文本框右边显示备注

1.var rightShowText = Ext.extend(Ext.util.Observable, {  
2.    init: function(field){  
3.        field.on("render",function(obj){  
4.            var font = document.createElement("font");     
5.            font.setAttribute("color","black");     
6.            font.setAttribute("className","rightShowText");     
7.            font.setAttribute("class","rightShowText");    
8.            var redStar = document.createTextNode(obj.rightTip);     
9.            font.appendChild(redStar);     
10.            obj.el.dom.parentNode.appendChild(font);     
11.        })  
12.        field.on("beforedestroy",function(obj){  
13.             var button = Ext.query("[class=rightShowText]", obj.el.dom.parentNode)[0];  
14.             Ext.removeNode(button);  
15.        })  
16.  
17.    }  
18.});
=====================================================================================================
1.{fieldLabel: '俩字',  
2.                     rightTip:"xxxx",  
3.                     xtype: 'textfield',  
4.                     plugins:new rightShowText()  
5.                    } 


=====================================================================================================  
1.{  
2.                                    xtype : "numberfield",  
3.                                    anchor : "70%",  
4.                                    fieldLabel : "综合平均电价",  
5.                                    name : "elePrice",  
6.                                    allowNegative : false,  
7.                                    allowBlank : true,  
8.                                    listeners : {  
9.                                        render : function(obj) {  
10.                                            var font = document.createElement("font");  
11.                                            font.setAttribute("color","black");  
12.                                            var redStar = document.createTextNode('元/kW.h');  
13.                                            font.appendChild(redStar);  
14.                                            obj.el.dom.parentNode.appendChild(font);  
15.                                        }  
16.                                    }  
17.                                }  
===================================================================================================
原文地址:https://www.cnblogs.com/FredTang/p/2765745.html