Ext JS 6 现代工具包时间选择器字段?
Ext JS 6 modern toolkit Time picker field?
Ext JS 6 现代工具包中是否有 time picker field
类似 Datetimepicker
的字段?我复制了 Sencha touch 2 时间选择器字段,但它在 Ext JS 6 现代应用程序中不起作用。有什么解决办法吗?
这就是我想出的
Create a file in 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
},
Ext JS 6 现代工具包中是否有 time picker field
类似 Datetimepicker
的字段?我复制了 Sencha touch 2 时间选择器字段,但它在 Ext JS 6 现代应用程序中不起作用。有什么解决办法吗?
这就是我想出的
Create a file in 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
},