修改Ext.form.DateField:
onTriggerClick : function () ... {
if(this.disabled)...{
return;
}
if(this.menu == null)...{
this.menu = new Ext.menu.DateMenu();
}
Ext.apply(this.menu.picker, ...{
minDate : this.minValue,
maxDate : this.maxValue,
disabledDatesRE : this.ddMatch,
disabledDatesText : this.disabledDatesText,
disabledDays : this.disabledDays,
disabledDaysText : this.disabledDaysText,
format : this.format,
minText : String.format(this.minText, this.formatDate(this.minValue)),
maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
input: this//davi
});
this.menu.on(Ext.apply(...{}, this.menuListeners, ...{
scope:this
}));
this.menu.picker.setValue(this.getValue() || new Date());
this.menu.show(this.el, "tl-bl?");
}
...
修改Ext.DatePicker:
...
onRender : function (container, position) ... {
//增加id:date_daysdate_bottom 用来隐藏days davi
var m = [
'<table cellspacing="0">',
'<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">*</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">*</a></td></tr>',
'<tr id="date_days"><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
...
m[m.length] = '</tr></tbody></table></td></tr><tr id="date_bottom"><td colspan="3" class="x-date-bottom" align="center"></td></tr></table>';
...
if(Ext.isIE)...{
this.el.repaint();
}
this.update(this.value);
...
//如果日期格式为Y年m月 则不显示日 davi
if(this.format == 'Y年m月')...{
Ext.get('date_days').hide();
Ext.get('date_bottom').hide();
}
/**//**/
} ,
update : function (date) ... {
...
for(; i < 42; i++) ...{
textEls[i].innerHTML = (++extraDays);
d.setDate(d.getDate()+1);
cells[i].className = "x-date-nextday";
setCellClass(this, cells[i]);
}
//如果日期格式为Y年m月 则不显示日 davi
if(this.format == 'Y年m月' && this.getValue() != date)...{
this.input.setValue(date);
this.input.fireEvent("select", date, this.input);
}
/**//**/
...
}
onTriggerClick : function () ... {
if(this.disabled)...{
return;
}
if(this.menu == null)...{
this.menu = new Ext.menu.DateMenu();
}
Ext.apply(this.menu.picker, ...{
minDate : this.minValue,
maxDate : this.maxValue,
disabledDatesRE : this.ddMatch,
disabledDatesText : this.disabledDatesText,
disabledDays : this.disabledDays,
disabledDaysText : this.disabledDaysText,
format : this.format,
minText : String.format(this.minText, this.formatDate(this.minValue)),
maxText : String.format(this.maxText, this.formatDate(this.maxValue)),
input: this//davi
});
this.menu.on(Ext.apply(...{}, this.menuListeners, ...{
scope:this
}));
this.menu.picker.setValue(this.getValue() || new Date());
this.menu.show(this.el, "tl-bl?");
}
...
修改Ext.DatePicker:
...
onRender : function (container, position) ... {
//增加id:date_daysdate_bottom 用来隐藏days davi
var m = [
'<table cellspacing="0">',
'<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">*</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">*</a></td></tr>',
'<tr id="date_days"><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
...
m[m.length] = '</tr></tbody></table></td></tr><tr id="date_bottom"><td colspan="3" class="x-date-bottom" align="center"></td></tr></table>';
...
if(Ext.isIE)...{
this.el.repaint();
}
this.update(this.value);
...
//如果日期格式为Y年m月 则不显示日 davi
if(this.format == 'Y年m月')...{
Ext.get('date_days').hide();
Ext.get('date_bottom').hide();
}
/**//**/
} ,
update : function (date) ... {
...
for(; i < 42; i++) ...{
textEls[i].innerHTML = (++extraDays);
d.setDate(d.getDate()+1);
cells[i].className = "x-date-nextday";
setCellClass(this, cells[i]);
}
//如果日期格式为Y年m月 则不显示日 davi
if(this.format == 'Y年m月' && this.getValue() != date)...{
this.input.setValue(date);
this.input.fireEvent("select", date, this.input);
}
/**//**/
...
}
用法:
var date = new Ext.form.DateField( ... {
...
format: 'Y年m月',
...
} );
date.applyTo( ' date ' );
date.on( ' select ' , function () ... {...} );
var date = new Ext.form.DateField( ... {
...
format: 'Y年m月',
...
} );
date.applyTo( ' date ' );
date.on( ' select ' , function () ... {...} );