效果如下:
Ext.ux.DateTime.js
/**
* @author baiyang
* @date 2013-04-10 23:28:02
*/
Ext.define('Ext.ux.form.TimePickerField', {
extend : 'Ext.form.field.Base',
alias : 'widget.timepicker',
alternateClassName : 'Ext.form.field.TimePickerField',
requires : [ 'Ext.form.field.Number' ],
// 隐藏BaseField的输入框 , hidden basefield's input
inputType : 'hidden',
style : 'padding:4px 0 0 0;margin-bottom:0px',
/**
* @cfg {String} value initValue, format: 'H:i:s'
*/
value : null,
/**
* @cfg {Object} spinnerCfg 数字输入框参数, number input config
*/
spinnerCfg : {
width : 40
},
/** Override. */
initComponent : function() {
var me = this;
me.value = me.value || Ext.Date.format(new Date(), 'H:i:s');
me.callParent();// called setValue
me.spinners = [];
var cfg = Ext.apply({}, me.spinnerCfg, {
readOnly : me.readOnly,
disabled : me.disabled,
style : 'float: left',
listeners : {
change : {
fn : me.onSpinnerChange,
scope : me
}
}
});
me.hoursSpinner = Ext.create('Ext.form.field.Number', Ext.apply({}, cfg, {
minValue : 0,
maxValue : 23
}));
me.minutesSpinner = Ext.create('Ext.form.field.Number', Ext.apply({}, cfg, {
minValue : 0,
maxValue : 59
}));
me.secondsSpinner = Ext.create('Ext.form.field.Number', Ext.apply({}, cfg, {
minValue : 0,
maxValue : 59
}));
me.spinners.push(me.hoursSpinner, me.minutesSpinner, me.secondsSpinner);
},
/**
* @private Override.
*/
onRender : function() {
var me = this, spinnerWrapDom, spinnerWrap;
me.callParent(arguments);
// render to original BaseField input td
// spinnerWrap = Ext.get(Ext.DomQuery.selectNode('div', this.el.dom));