gpt4 book ai didi

extjs - Ext JS 6 现代工具包时间选择器字段?

转载 作者:行者123 更新时间:2023-12-04 03:05:58 24 4
gpt4 key购买 nike

在 Ext JS 6 现代工具包中是否有类似 Datetimepicker 字段的 time picker 字段?我复制了 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
},

关于extjs - Ext JS 6 现代工具包时间选择器字段?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44342936/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com