日期控件增加背景颜色

Ext.define('Dms.field.DWorkDatePicker', {
extend: 'Ext.picker.Date',
alias: 'widget.Dworkdatepicker',
todayText: '今天',
requires: ['Dms.field.DTimePicker'],
id:'Dworkdatepicker',
initComponent: function() {
var value = this.value || new Date();
this.callParent();
this.value = value;
},
update: function(date){
var me = this;
me.callParent(arguments);
me.fireEvent('afterUpdate', me, date);
noDays = [];
//----------获取xx年xx月-----------------
var headerdatedom = Ext.get('Dworkdatepicker-innerEl').dom;
var headerdate;
// if(Ext.isIE8) {
headerdate = headerdatedom.innerText.replace('\r\n','').replace('年','-').replace('月','');
headerdate = headerdate.substr(0,7);
headerdate = headerdate+"-01";
// } else {
// headerdate = headerdatedom.textContent.replace('年','-').replace('月','');
// }
var submitValues = "";
var url='msg/receivemsgshowquery?headerdate='+headerdate;
var successFunc = function(result){
// var date = result.data[0].sendtime;
for(var i=0;i noDays.push(result.data[i].sendtime.substr(0,10));
}
me.updateFlag(date, noDays);
}
var failFunc = function(result){
alert(result.message);
}
Ext.create('Dms.util.SubmitUtil').doAjaxRequest(submitValues, url, successFunc, failFunc);
//=============================end=================
},
updateFlag: function(date, noDays){
var me = this;
//改变minDate颜色'

/*var min = Ext.util.Format.date(Ext.Date.add(new Date(), Ext.Date.DAY, -6),'d');

min = min.replace(/\b(0+)/gi, "");
var max = Ext.util.Format.date(new Date(),'d');
max = max.replace(/\b(0+)/gi, "");
var tt = document.getElementsByClassName('x-datepicker-date');
for(var j =0; j < min; j++ ) {
tt[j].style.backgroundColor = "#EEEEEE";
}*/

if(!noDays) noDays = [];
for(var i=0;i var tdEl = me.cells.elements[i];
var isActive = Ext.get(tdEl).hasCls('x-datepicker-active');
tdEl.style.backgroundColor = "white";
var val = Ext.get(tdEl).down('a').dom.innerHTML;
var month = date.getMonth()+1;
var year = date.getFullYear();
var valDate = Ext.Date.format(Ext.Date.parseDate(year+'-' + month + '-' + parseInt(val), 'Y-n-j'), 'Y-m-d');

if(!isActive){
continue;
}
if(Ext.Array.contains(noDays, valDate)){
// Ext.DomHelper.append(tdEl, '');
tdEl.style.backgroundColor = "#FFF68F";
console.log("success");
}
}
}

})




日期控件增加背景颜色_第1张图片

你可能感兴趣的:(ExtJs)