PDA

View Full Version : New Feature: TimeField minDisplayTime/maxDisplayTime



Scott Murawski
3 Dec 2009, 11:06 AM
I want a convenient short list of times to display to the user but at the same time accept any time. For example, if you are scheduling something primarily during the day but still want to accept the odd early or late hours too which the user can type in.

The usage for minDisplayTime / maxDisplayTime is exactly as you use minValue/maxValue (except only the display is affected and not the validation).

This is Ext 3.0.0 code


Ext.override(Ext.form.TimeField, {
initComponent : function(){
if(typeof this.minValue == "string"){
this.minValue = this.parseDate(this.minValue);
}
if(typeof this.maxValue == "string"){
this.maxValue = this.parseDate(this.maxValue);
}

if(!this.store){
var min = this.parseDate(this.minValue)
|| this.parseDate(this.minDisplayValue)
|| new Date(this.initDate).clearTime();
var max = this.parseDate(this.maxValue)
|| this.parseDate(this.maxDisplayValue)
|| new Date(this.initDate).clearTime().add('mi', (24 * 60) - 1);
var times = [];
while(min <= max){
times.push(min.dateFormat(this.format));
min = min.add('mi', this.increment);
}
this.store = times;
}
Ext.form.TimeField.superclass.initComponent.call(this);
}
});