您的位置:首页 > Web前端 > JavaScript

extjs日期输入控件

2015-01-05 11:21 399 查看
/**

* 带时间的日期输入控件

*/

Ext.define('js文件的地址', {

extend:'Ext.form.field.Date',

alias: 'js文件的地址别名',

requires: ['ketech.view.ux.picker.DateTime'],

/**

* @cfg {String} format

* The default date format string which can be overriden for localization support. The format must be valid

* according to {@link Ext.Date#parse}.

*/

format : "Y-m-d H:i:s",

/**

* @cfg {String} altFormats

* Multiple date formats separated by "|" to try when parsing a user input value and it does not match the defined

* format.

*/

altFormats : "Y-m-d H:i:s",

createPicker: function() {

var me = this,

format = Ext.String.format;

//修改picker为自定义picker

return new ketech.view.ux.picker.DateTime({

pickerField: me,

ownerCt: me.ownerCt,

renderTo: document.body,

floating: true,

hidden: true,

focusOnShow: true,

minDate: me.minValue,

maxDate: me.maxValue,

disabledDatesRE: me.disabledDatesRE,

disabledDatesText: me.disabledDatesText,

disabledDays: me.disabledDays,

disabledDaysText: me.disabledDaysText,

format: me.format,

showToday: me.showToday,

startDay: me.startDay,

minText: format(me.minText, me.formatDate(me.minValue)),

maxText: format(me.maxText, me.formatDate(me.maxValue)),

listeners: {

scope: me,

select: me.onSelect

},

keyNavConfig: {

esc: function() {

me.collapse();

}

}

});

},

/**

* @private

*/

onExpand: function() {

var value = this.getValue();

//多传一个参数,从而避免时分秒被忽略。

this.picker.setValue(Ext.isDate(value) ? value : new Date(), true);

}

});

然后在其他js文件中引入就可以了

items : [

Ext.create(''js文件的地址', {

name : 'beginTime',

fieldLabel : '开始时间/结束时间',

format : 'Y-m-d H:i:s',

labelAlign : 'right',

labelWidth : 90,

listeners : {

select : function(){

this.pickerBeginTime = this.getValue();

this.up("panel").down("datetimefield[name=endTime]").setMinValue(this.pickerBeginTime);

}

}

}),
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: