PDA

View Full Version : [OPEN-1339] Datefield: setDisabledDates Bug (setting empty again)



Spirit
15 Oct 2010, 5:05 AM
Hi!

i m unable to set DisabledDates empty again, after i have used it.
If i try to initialize a empty array all dates are disabled. (may be this behavior is wanted, but how to set it empty again ?)

Testcase


Ext.onReady(function(){

Ext.form.DateField.prototype.clearDates=function() {
this.disabledDatesRE = null;
this.disabledDates = null;
}


var win;
var button = Ext.get('show-btn');

var dDates=["30.10.2010"];
var edVon=new Ext.form.DateField ({
xtype: 'datefield',
allowBlank: true,
format: 'd.m.Y',
disabledDates:dDates
})


button.on('click', function(){
if(!win){
win = new Ext.Window({
applyTo:'hello-win',
layout:'fit',
width:500,
height:300,
closeAction:'hide',
plain: true,
items:edVon,
buttons: [{
text:'Add to disabledDate',
handler:function() {
edVon.setDisabledDates(["30.10.2010","25.10.2010"]);
}
},{
text:'Remove disabled Dates',
handler:function() {
//edVon.clearDates(); // with this line of code it will work, see prototype at top of file
edVon.setDisabledDates(null); // tried null, undefined, empty array, '' but nothing worked
}
}]
});
}
win.show(this);
});
});


If someone has the same Problem, see prototype on top for temporary solution.

Greetz
Spirit

meroy
15 Oct 2010, 2:28 PM
Can you provide the version of Ext JS you were using? Thanks.

http://www.sencha.com/forum/showthread.php?71015-Posting-to-the-Bug-Forum

Spirit
17 Oct 2010, 11:23 PM
I m using Ext 3.3 / FF3.6.1 / Win7

Condor
17 Oct 2010, 11:58 PM
Suggested patch:

Ext.override(Ext.form.DateField, {
initComponent : function(){
Ext.form.DateField.superclass.initComponent.call(this);
this.addEvents(
'select'
);
if(Ext.isString(this.minValue)){
this.minValue = this.parseDate(this.minValue);
}
if(Ext.isString(this.maxValue)){
this.maxValue = this.parseDate(this.maxValue);
}
/*this.disabledDatesRE = null;*/
this.initDisabledDays();
},
initDisabledDays : function(){
if(this.disabledDates){
var dd = this.disabledDates,
len = dd.length - 1,
re = "(?:";
Ext.each(dd, function(d, i){
re += Ext.isDate(d) ? '^' + Ext.escapeRe(d.dateFormat(this.format)) + '$' : dd[i];
if(i != len){
re += '|';
}
}, this);
this.disabledDatesRE = new RegExp(re + ')');
} else {
this.disabledDatesRE = null;
}
}
});

julien.b
2 Nov 2010, 2:29 AM
Hi,

Thanks for the patch !

In addition,

The documentation of ExtJS 3.3.0 says that default format in Ext.form.DateField is 'm/d/Y'.
In fact, the default format in 3.3.0 is 'm/d/y'.
The examples provided in the documentation may not work as well.

Regards