当前位置:编程学习 > JS >>

Extjs 3.3.1 日历组件,只选择年月

xtype:'datefield',
format :'Y-m'
/*重写时间显示模板*/
if (Ext.DatePicker) {
    Ext.apply(Ext.DatePicker.prototype, {
        createMonthPicker: function () {
            if (!this.monthPicker.dom.firstChild) {
                var buf = ['<table border="0" cellspacing="0">'];
                for (var i = 0; i < 6; i++) {
                    buf.push(
                        '<tr>',
                        i === 0 ?
                        '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn x-date-mp-sep" align="center"><a class="x-date-mp-next"></a></td>' :
                        '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year x-date-mp-sep"><a href="#"></a></td>',
                        '<td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i), '</a></td>',
                        '<td class="x-date-mp-month"><a href="#">', Date.getShortMonthName(i + 6), '</a></td>',
                        '</tr>'
                    );
                }
                buf.push(
                    '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
                        this.okText,
                        '</button><button type="button" class="x-date-mp-cancel">',
                        this.cancelText,
                        '</button></td></tr>',
                    '</table>'
                );
                this.monthPicker.update(buf.join(''));
                this.mon(this.monthPicker, 'click', this.onMonthClick, this);
                this.mon(this.monthPicker, 'dblclick', this.onMonthDblClick, this);
                this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
                this.mpYears = this.monthPicker.select('td.x-date-mp-year');
                this.mpMonths.each(function (m, a, i) {
                    i += 1;
                    if ((i % 2) === 0) {
                        m.dom.xmonth = 5 + Math.round(i * 0.5);
              &n
补充:web前端 , JavaScript ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,