Ext.apply(Ext.form.VTypes, {
daterange : function(val, field) {
var date = field.parseDate(val);
if (!date) {
return;
}
if (field.startDateField
&& (!this.dateRangeMax || (date.getTime() != this.dateRangeMax
.getTime()))) {
var start = Ext.getCmp(field.startDateField);
start.setMaxValue(date);
start.validate();
this.dateRangeMax = date;
} else if (field.endDateField
&& (!this.dateRangeMin || (date.getTime() != this.dateRangeMin
.getTime()))) {
var end = Ext.getCmp(field.endDateField);
end.setMinValue(date);
end.validate();
this.dateRangeMin = date;
}
return true;
}
daterange : function(val, field) {
var date = field.parseDate(val);
if (!date) {
return;
}
if (field.startDateField
&& (!this.dateRangeMax || (date.getTime() != this.dateRangeMax
.getTime()))) {
var start = Ext.getCmp(field.startDateField);
start.setMaxValue(date);
start.validate();
this.dateRangeMax = date;
} else if (field.endDateField
&& (!this.dateRangeMin || (date.getTime() != this.dateRangeMin
.getTime()))) {
var end = Ext.getCmp(field.endDateField);
end.setMinValue(date);
end.validate();
this.dateRangeMin = date;
}
return true;
}
});
var toolbar = new Ext.Toolbar( {
height : 30,
items : [
'入库时间:', {
xtype : "datefield",
name : "startDate",
id : "startDate1",
editable : false,
endDateField : "endDate1",
vtype : 'daterange',
emptyText : '请选择',
format : 'Y-m-d',
labelWidth : 70,
anchor : "90%"
}, "至:", {
xtype : "datefield",
name : "endDate",
id : "endDate1",
vtype : 'daterange',
startDateField : "startDate1",
editable : false,
emptyText : '请选择',
format : 'Y-m-d',
labelWidth : 70,
anchor : "90%"
}]