Extjs DatePicker:如何启用'点击/选择'在鼠标点击禁用日期?

时间:2016-07-29 16:09:04

标签: extjs

我使用Extjs 4.2.5 datepicker进行会议管理,当用户选择一个日期我将其添加到一个数组然后调用' setdisableDates':

enter image description here

sender.DisabledDates.push(date); 
sender.setDisabledDates(sender.DisabledDates); 

用户选择日期后,它将变为禁用状态,使用css我将背景颜色更改为红色。

如果用户犯了错误并想要取消,我如何在已禁用的日期启用点击或选择?

谢谢你的建议

1 个答案:

答案 0 :(得分:0)

我设法通过覆盖" handleDateClick":

来实现



function picker.beforeInit(sender, config)
{
  config.cls='room_clndr';
  config.DisabledDates=[];
  config.disabledDaysText='חסום';
  config.handleDateClick = function(e, t){
        var me = this,
        handler = me.handler;        
        e.stopEvent();
        if(!me.disabled && t.dateValue){//<---------
            me.doCancelFocus = me.focusOnSelect === false;
            me.setValue(new Date(t.dateValue));
            delete me.doCancelFocus;
            me.fireEvent('select', me, me.value);
            if (handler) {
                handler.call(me.scope || me, me, me.value);
            }
            me.onSelect();
        }
    } 
}
&#13;
&#13;
&#13;

&#13;
&#13;
function picker.select(sender, date, eOpts)
{
   if(jQuery.inArray( Ext.Date.format(date, 'd/m/Y'), sender.DisabledDates )>=0) {
      sender.DisabledDates.splice( $.inArray(Ext.Date.format(date, 'd/m/Y'), sender.DisabledDates), 1 );
      if(sender.DisabledDates.length>0) {
       sender.setDisabledDates(sender.DisabledDates);
      }
      else {
       sender.setDisabledDates([null]);
      }        
   }
   else {
    sender.DisabledDates.push(Ext.Date.format(date, 'd/m/Y'));
    sender.setDisabledDates(sender.DisabledDates);    
   } 
}
&#13;
&#13;
&#13;

这里是css:

&#13;
&#13;
.room_clndr .x-datepicker-disabled .x-datepicker-date
{
 background-color:#fe5757 !important;
 color: #fff !important; 
}
&#13;
&#13;
&#13;