PDA

View Full Version : [2.2][FIXED] DateField disabledDates no longer working



maggiesnyder
20 Aug 2008, 1:30 PM
Hi ExtJS Team,
I just upgraded to Ext 2.2.0. I'm using a DateField with disabledDates and this feature is no longer working (it worked just fine before).

By "no longer working" I mean that none of the dates are greyed out that should be. The min and max dates both work, but I'm not able to disable dates.



if (typeof dateList!='undefined') {disabled= ["^(?!"+dateList.join("|")+").*$"];}
else {disabled= ["^"];}
var calendarField= new Ext.form.DateField({
fieldLabel: 'Select a Date',
name: 'date',
id: 'date',
format:'Y-m-d',
minValue:'2006-01-12',
maxValue:'2008-08-20',
disabledDates:disabled
});
I'm looking at the ext-all.js code for DateField and so far I haven't fixed it... any chance you guys can take a look? I think it might have something to do with ddMatch and disabledDatesRE, if that helps.

Thanks,
Maggie

Condor
20 Aug 2008, 9:51 PM
Here is a fix:


Ext.override(Ext.form.DateField, {
initDisabledDays : function(){
if(this.disabledDates){
var dd = this.disabledDates;
var re = "(?:";
for(var i = 0; i < dd.length; i++){
re += this.formatDate(dd[i]);
if(i != dd.length-1) re += "|";
}
this.ddMatch = new RegExp(re + ")");
}
}
});

(I also added a call to formatDate to support localized dates correctly)

ps. It looks like somebody tried to rename ddMatch to disabledDatesRE to match the property name of Ext.DatePicker, but didn't do a full replace.

maggiesnyder
21 Aug 2008, 8:41 AM
Awesome, excellent, thank you!

mystix
11 Nov 2008, 6:22 PM
someone else just encountered this again:
http://extjs.com/forum/showthread.php?t=52456

Sam
12 Nov 2008, 1:58 PM
Hi I just tired implementing the override and for some reason it isn't disabling the dates I specified. Can anyone give me a clue as to what else needs to be done. I even went as far as modifying the ext-all-debug.js with the aforementioned fix.

jack.slocum
15 Nov 2008, 3:54 PM
This is fixed in SVN. All spots referencing the old var (ddMatch) have been updated to use disableDatesRE.

dreitman
26 Jan 2009, 8:02 AM
Here is a fix:


Ext.override(Ext.form.DateField, {
initDisabledDays : function(){
if(this.disabledDates){
var dd = this.disabledDates;
var re = "(?:";
for(var i = 0; i < dd.length; i++){
re += this.formatDate(dd[i]);
if(i != dd.length-1) re += "|";
}
this.ddMatch = new RegExp(re + ")");
}
}
});(I also added a call to formatDate to support localized dates correctly)

ps. It looks like somebody tried to rename ddMatch to disabledDatesRE to match the property name of Ext.DatePicker, but didn't do a full replace.


If you use setDisabledDates() you will also need to override that mehtod as well:


Ext.override(Ext.form.DateField, {
setDisabledDates : function(dd){
this.disabledDates = dd;
this.initDisabledDays();
if(this.menu)
{
this.menu.picker.setDisabledDates(this.ddMatch);
}
}
});

chevanton19
5 May 2009, 1:36 AM
i put on the fix on my code, probably i'm doin something wrong 'cause my datepickers yet have no disabled dates as inetnded.
any help on where i have to put the fixes on?
i put em in an utility file in used to store some often-used functions.

sorry for poor english

tanks to any who can help

bye
- daniele

sijuthomasp
7 Dec 2010, 1:58 PM
Hi All,

I was just trying to make few dates disabled which is coming from DB. I couldn't find a way to make it work and finally this post helped me to fix the issue. Thanks a lot.

Regards,
STP.

wsilvius
23 Dec 2010, 2:47 PM
i still got that "error"... i put that fix into my code but still doesn't work, where i could put the fix code..? i don't know
:S