extjs日期控件只能选择年月问题

zhaojinmeng 2015-08-11 04:43:50
我扩展了一下Ext.form.field.Date控件,出现的问题是控件展开后,只要点一下,控件就消失了,无法选择
代码:
Month.js:
Ext.define('Ext.form.field.Month', {
extend : 'Ext.form.field.Date',
alias : 'widget.monthfield',
requires : ['Ext.picker.Month'],
alternateClassName : ['Ext.form.MonthField', 'Ext.form.Month'],
selectMonth : null,
createPicker : function() {
var me = this, format = Ext.String.format;
return Ext.create('Ext.picker.Month', {
pickerField : me,
height:190,
ownerCt : me.ownerCt,
renderTo : document.body,
floating : true,
hidden : true,
focusOnShow : true,
minDate : me.minValue,
maxDate : me.maxValue,
disabledDatesRE : me.disabledDatesRE,
disabledDatesText : me.disabledDatesText,
disabledDays : me.disabledDays,
disabledDaysText : me.disabledDaysText,
format : me.format,
showToday : me.showToday,
startDay : me.startDay,
minText : format(me.minText, me.formatDate(me.minValue)),
maxText : format(me.maxText, me.formatDate(me.maxValue)),
listeners : {
select : {scope : me, fn : me.onSelect },
monthdblclick : {scope : me, fn : me.onOKClick},
yeardblclick : {scope : me, fn : me.onOKClick},
OkClick : {scope : me, fn : me.onOKClick},
CancelClick : {scope : me, fn : me.onCancelClick}
},
keyNavConfig : {
esc : function() {
me.collapse();
}
}
});
},
onCancelClick : function() {
var me = this;
me.selectMonth = null;
me.collapse();
},
onOKClick : function() {
var me = this;
if (me.selectMonth) {
me.setValue(me.selectMonth);
me.fireEvent('select', me, me.selectMonth);
}
me.collapse();
},
onSelect : function(m, d) {
var me = this;
me.selectMonth = new Date((d[0] + 1) + '/1/' + d[1]);
}
});
...全文
608 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
觅夜的黑 2016-09-26
  • 打赏
  • 举报
回复
这种他不是写好了吗? 直接用就好了,为什么要重写呢
像忘了谁sq 2016-09-26
  • 打赏
  • 举报
回复
首先js 有没有报错,没有报错。则是js代码控制显示有问题。1.触发的事件有问题,2.设置控件的display 属性有问题
_在路上_ 2016-09-26
  • 打赏
  • 举报
回复
现在遇到同样的问题 是什么原因啊
zhaojinmeng 2015-08-11
  • 打赏
  • 举报
回复
引用 5 楼 rui888 的回复:
调试到源码里啊。没有环境怎么知道那句错误了。 其次你再换其他浏览器看看,画面有没有js 错误。扑住画面的事件 到源码里面调试看看吧。
其他浏览器也是这情况,我现在就是一点击,控件就关闭了,无法触发选择事件
tony4geek 2015-08-11
  • 打赏
  • 举报
回复
调试到源码里啊。没有环境怎么知道那句错误了。 其次你再换其他浏览器看看,画面有没有js 错误。扑住画面的事件 到源码里面调试看看吧。
zhaojinmeng 2015-08-11
  • 打赏
  • 举报
回复
引用 2 楼 rui888 的回复:
自己去调试看看
已经跟了好多遍了,点击确定和取消按钮可以出发监听事件,点击其他地方,控件立马消失
zhaojinmeng 2015-08-11
  • 打赏
  • 举报
回复

只要点击框的范文内,框就消失了根本无法选择
tony4geek 2015-08-11
  • 打赏
  • 举报
回复
自己去调试看看
zhaojinmeng 2015-08-11
  • 打赏
  • 举报
回复
使用的地方: xtype: 'monthfield', fieldLabel: '所属月份', labelWidth: 36, width: 156, format: 'Y-m', anchor: '100%', altFormats: 'm,Y|m.Y', id: 'monthfield_id', value: 'new', 实在找不出问题出在哪

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧