Ext JS 6现代工具包中是否有time picker field
个Datetimepicker
字段?我复制了Sencha touch 2 Time选择器字段,但它在Ext JS 6现代应用程序中无效。任何解决方案?
答案 0 :(得分:4)
所以这就是我想出来的
在ext / modern / modern / src / field / TimePicker.js
中创建一个文件
现在将波纹管代码粘贴到文件
中Ext.define('Ext.field.TimePicker', {
extend: 'Ext.field.Text',
alternateClassName: 'Ext.form.TimePicker',
xtype: 'timepickerfield',
requires: [
'Ext.field.trigger.Clear'
],
setMe: function(t){
this.val = t;
},
getMe: function(){
return this.val;
},
initialize: function (a, b, c) {
var me = this;
me.getComponent().on({
keyup: 'onKeyUp',
input: 'onInput',
focus: 'onFocus',
blur: 'onBlur',
paste: 'onPaste',
mousedown: 'onMouseDown',
scope: this
});
},
listeners: {
focus: function (a, b, c, d) {
var me = this,
hours = new Array(),
minutes = new Array(),
seconds = new Array(),
i=0;
// for hours
while(i < 24){
var j = i;
if(i < 10) j = '0'+''+j;
hours.push({
text: j,
value: j
});
i++
}
// for minutes
i = 0;
while(i < 60){
var j = i;
if(i < 10) j = '0'+''+j;
minutes.push({
text: j,
value: j
});
i += 5;
}
// for Seconds
i = 0;
while(i < 60){
var j = i;
if(i < 10) j = '0'+''+j;
seconds.push({
text: j,
value: j
});
i += 5;
}
var picker = Ext.create('Ext.Picker', {
useTitles: true,
listeners: {
change: function (picker, value, eOpts) {
me.setValue(value.hour + ':' + value.minute + ':' + value.second);
}
},
align: 'center',
slots: [{
xtype: 'spacer'
},{
name: 'hour',
title: 'Hour',
data: hours
}, {
name: 'minute',
title: 'Minute',
data: minutes
},{
name: 'second',
title: 'Second',
data: minutes
},{
xtype: 'spacer'
}]
});
picker.show();
}
}
});
并在其他领域使用它
{
xtype: 'timepickerfield',
name: 'time',
label: 'Time',
// other field options
},