修改Ext.form.DateField只选择年月

修改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);
}

/**/
...
}
 
用法:
var  date  =   new  Ext.form.DateField( {
...
format: 
'Y年m月',
...
}
);
date.applyTo(
' date ' );
date.on(
' select ' , function () {...} );

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值