ext datafield applyto

<HTML>
<HEAD>
  <TITLE></TITLE>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <link rel="stylesheet" type="text/css" href="../../extjs2.0/resources/css/ext-all.css" />
  <script type="text/javascript" src="../../extjs2.0/adapter/ext/ext-base.js"></script>
  <script type="text/javascript" src="../../extjs2.0/ext-all.js"></script>
  <script type="text/javascript" src="../../extjs2.0/source/locale/ext-lang-zh_CN.js"></script>
            <script type="text/javascript">
        Ext.onReady(function(){
        var date = new Ext.form.DateField({
            fieldLabel : '选择日期',
            format : 'Y年m月d日',
            width : 150,
            maxValue :'12/31/2009',//允许选择的最大日期
            minValue :'12/01/2009',//允许选择的最小日期
            onTriggerClick:function()
            {
                if(this.menu == null){
                this.menu = new Ext.menu.DateMenu();
                }
                var sss=Ext.apply(this.menu.picker, {
                minDate : this.minValue,
                maxDate : this.maxValue,
                format : this.format,
                minText : String.format(this.minText, this.formatDate(this.minValue)),
                maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
                activeDate:this.minValue,//设置活动日期
                input: this
                });
                this.menu.on(Ext.apply({}, this.menuListeners, {
                scope:this
                }));
                this.menu.show(this.el, "tl-bl?");
            }
        });
        date.render("mydate");
        });
        </script>
</HEAD>
<BODY >
        <div id="mydate"></div>
</BODY>
</HTML>














加监听事件
menuListeners : {
beforeshow : function() {
var myDate=new Date();
myDate.setFullYear(1970,0,1);
this.menu.picker.setValue(this.getValue()||myDate);

},
select : function(m, d) {
this.setValue(this.menu.picker.getValue());
}
}
即可

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