重写时间控件,只有选择年月的界面

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 01:21 点击:

下面是在ext官方网站上down的一个函数只显示年和月,不显示日
// in the .html
<span id="curMonthDiv">&nbsp;</span>


// in the .js
myApp.app = function() {
    var monthPicker = null;

    return {
        init: function() {

            monthPicker = new Ext.ux.MonthField({
                format:      'M, Y',
                useDayDate:  1,
                noPastYears: true,
                renderTo:    'curMonthDiv',
                monthNames:  [ /* month names... */ ]
            });
            // #1: This works, but still turns the text input gray/doesn't look good
            monthPicker.el.dom.readOnly = true;

            // add listener for when the OK button is clicked (go to new month)
            // #2: doesn't work
            monthPicker.on("select", function(picker, selDate) {
                // go to the new month - contact server...
                // When I select the month and hit the OK btn, this code is not reached
            });

            monthPicker.setValue(new Date()); // today
        } // end init()
    }; // end return
}(); // end myApp.app

----------------------------------------------
下面是我同事扩展的:

Ext.ux.MonthPicker=Ext.extend(Ext.Component,{
format:"M-y",
okText:Ext.DatePicker.prototype.okText,
cancelText:Ext.DatePicker.prototype.cancelText,
constrainToViewport:true,
monthNames:Date.monthNames,
startDay:0,
value:0,
noPastYears:false,
initComponent:function () {
Ext.ux.MonthPicker.superclass.initComponent.call(this);
this.value=this.value?
this.value.clearTime():new Date().clearTime();
this.addEvents(
'select'
);
if(this.handler) {
this.on("select",this.handler,this.scope||this);
}
},
focus:function () {
if(this.el) {
this.update(this.activeDate);
}
},
onRender:function (container,position) {
var m=['<div style="width: 200px; height:175px;"></div>']
m[m.length]='<div class="x-date-mp"></div>';
var el=document.createElement("div");
el.className="x-date-picker";
el.innerHTML=m.join("");
container.dom.insertBefore(el,position);
this.el=Ext.get(el);
this.monthPicker=this.el.down('div.x-date-mp');
this.monthPicker.enableDisplayMode('block');
this.el.unselectable();
this.showMonthPicker();
if(Ext.isIE) {
this.el.repaint();
}
this.update(this

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • Gb2312转utf-8编码的方法(vbs+js)
      • 如何使用Ajax技术开发Web应用程序(1)
      • js跳转路径问题
      • JavaScript模仿桌面窗口
      • 用js检测两个线段是否相交
      • 运用JavaScript构建你的第一个Metro式应用程序(on Windows
      • 我知道的JavaScript -- 设计模式(桥接)应用之 – 验证器
      • 我是如何去了解jquery的(六),案例之幻灯片轮换
      • Jquery封装幻灯片效果
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1