让普通的input=text弹出DatePicker

只要设置好id就行了,其他参数配置默认Ext.DatePicker

 

html 如下:

<input id='dateSign' type="text" size="10"> 

 js如下:

 

/** 谢忠持 扩张插件 支持普通input=text显示日期 **/
Ext.ux.DatePicker = Ext.extend(Ext.DatePicker, {
	afterRender: function(){
		this.el.setStyle('position', 'absolute');
		this.el.setLeftTop(Ext.get(this.renderTo).getX(),Ext.get(this.renderTo).getY()+Ext.get(this.renderTo).getHeight());
		this.on("select",function(src,date){   
	    	Ext.getDom(this.renderTo).value=date.format(this.format);   
	    	this.hide();
	    });
		var datePicker = this;
		Ext.get(this.renderTo).on('click', function(){
			if(!datePicker.hidden){
				datePicker.hide();
			}else{
				datePicker.show(); 
			}
		});
	}
});

var dateSign = new Ext.ux.DatePicker({
         applyTo: "dateSign",   
         renderTo: "dateSign",    
         hidden: "true",   
         format: "Y-m-d"
});

 

你可能感兴趣的:(html,ext)