在“打开”日期字段中按键删除值,并关闭相关的日期戳 [英] keypress to delete value in 'open' datefield and close related datepicker
问题描述
我有一个ExtJS form.field.Date如下:
I have an ExtJS form.field.Date as below;
{
xtype: 'datefield',
name: 'X_Cut_Process_Completed_Date',
format: 'd M Y',
startDay: 1,
allowBlank: true,
editable: false,
listeners: {
specialkey: function(field, e){
if (e.getKey() == e.DELETE) {
field.setValue('');
}
}
}
}
被要求实施一个捕获Delete键的事件,同时正在编辑 datefield
(与关联的 datepicker
打开),它清除 datefield
的值,并关闭 datepicker
。现有的 specialkey
监听器只会清除该值,而 datefield
未被编辑。
I have been asked to implement an event that catches the Delete key while the datefield
is being edited (with the associated datepicker
open), that clears the value for the datefield
and closes the datepicker
. The existing specialkey
listener only clears the value while the datefield
is NOT being edited.
如何实现关闭 datefield
的 datepicker
的监听器,同时清除 datefield
的值?
How do I implement a listener that closes a datefield
's datepicker
and clear the datefield
's value simultaneously?
推荐答案
[更新]
您可以获取选择器并隐藏:
You can get the picker and hide it:
field.getPicker().hide()
我已经测试了它,它的工作原理。要测试你的账户:
I have tested it and it works. To test it for yoursef:
- 导航到 http://extjs.eu/software/form-field-icon-plugin/
-
在控制台类型中:
- navigate to http://extjs.eu/software/form-field-icon-plugin/
in console type:
Ext.ComponentQuery.query('datefield')[0].on('specialkey', function(field, e){
if(e.getKey() === e.DELETE) {
field.getPicker().hide();
field.setValue('');
}
});
现在在日期字段中打开选择器,输入内容并按删除。两个字段都被清除,并且选择器被隐藏。
Now open the picker in the date field, type something and press delete. Both the field is cleared and the picker is hidden.
这篇关于在“打开”日期字段中按键删除值,并关闭相关的日期戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!