PDA

View Full Version : [OPEN] DatePicker and changing disabledDays after first show



DanF
5 Jun 2007, 5:10 PM
Hi All

ext 1.01a, tested on FF 2 and IE7

I think I've found a bug with the DatePicker widget. If you set disabledDays after the picker has been shown once, the days on the first "screen" of the calendar don't change their disabled state. They do however change if you scroll forwards and back. I think it would also apply to setting minValue and maxValue if min and/or max are in the month that was last shown, but I haven't tested that bit. I should mention I'm using the DatePicker from within a DateMenu, and triggering the show from a div click

I've traced the bug to line 365 of DatePicker.js, which short circuits the setting of the classes based on the active month/year being the same as the selected month/year


update : function(date){
var vd = this.activeDate;
this.activeDate = date;

if(vd && this.el){
var t = date.getTime();
if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
//... inner code snipped
});
return;



I'm working around this by setting the private activeDate of the DatePicker to be a year fowards from the selected date each time I pop the DatePicker, but it smells like a nasty hack setting a private member!

I'd suggest either some methods for setMin, setMax, setDisabledDays, etc, but they could get rather verbose. A method called updateEnabledDates that then takes min+max+disabledDays+disabledDates etc could be handy as that's what I really want to do.

Loving ext btw, fantastic piece of kit!

Spirit
18 Sep 2007, 2:53 AM
Any solutions by now ?

jsakalos
18 Sep 2007, 2:56 PM
Does this issue still exist in 1.1.1?

Spirit
18 Sep 2007, 10:50 PM
Yes it does. (Ext 1.1.1)
I first thought i set them wrong until i found this thread.


If you set disabledDays after the picker has been shown once, the days on the first "screen" of the calendar don't change their disabled state. They do however change if you scroll forwards and back.

I have the same issue after setting the disabledDates to a new value. The first calender page shows the old values until i go forward a month and than backward. Now they are shown correctly.
Maybe i set the disabledDates a wrong way ?
Would be easier if there was a build in function for that ;)

Because i dont know how to avoid this, i am using always a new datefield. Not very nice, but it works :(

jsakalos
19 Sep 2007, 9:30 AM
Per the quote you've posted - if you set disabled dates before the picker is shown for the first time - does it solve the issue?

falcondot
19 Sep 2007, 11:54 PM
Hi Jozef ,

I am also facing the same problem , n if I set the minValue initially then is displays the css fine , but if I set the minValue from Javascript later on the css is not set immediately ...it is set only if I scroll month forward or backwards

Spirit
20 Sep 2007, 12:13 AM
Per the quote you've posted - if you set disabled dates before the picker is shown for the first time - does it solve the issue?

Yes that would solve the issue, but that is no option for me ;)

kylleblack
28 Sep 2007, 9:38 AM
I have a problem with minDate and maxDate and I resolved like this:
[CODE]
////this fields are in one Ext.form.Form
new Ext.form.DateField({
fieldLabel: 'Data de partida',
id: 'DatadePartida',
name: 'DatadePartida',
format: 'd/m/Y',
altFormats: 'd/m/Y|d-m-y|d-m-Y|d/m|d-m|d|dm|dmy|dmY',
maxText: 'Data de partida n

jsakalos
28 Sep 2007, 9:53 AM
I have notified Jack on this.

beaujo
30 Oct 2007, 12:07 PM
This is an other way of working around the bug without modifying directly the function at fault (namely, Ext.DatePicker.update). The following fix will apply to all datePickers in your app:



// ToDo: remove these lines once the following ext bug is fixed:
// the minDate and maxDate do not get updated once the datepicker has been rendered once
Ext.DatePicker.prototype._OldMinDate = null;
Ext.DatePicker.prototype._OldMaxDate = null;
Ext.DatePicker.prototype.setValue = function (value) {
var old = this.value;
this.value = value.clearTime(true);
if(this.el){
// If min or max date changed, then apply the bug fix
if (this._OldMinDate != this.minDate || this._OldMaxDate != this.maxDate) {
this.update(this.activeDate.add("mo", 1));
this._OldMinDate = this.minDate;
this._OldMaxDate = this.maxDate;
}
this.update(this.value);
}
},