我想从月2日到月最后一天禁用。
即仅在每月的第一天启用。也应该禁用本月的第一天。我试过
format: 'd/m/Y',
disabledDates: ['02/..', '31/..']
但它仅在每月的2日和31日禁用。
虽然我搜索更多
使用
disabledDates : ['^01']
它帮助我禁用每个月的1号。。。但是我需要相反的答案。
请帮助::extjs 新手
不漂亮,但下面是代码片段。
请注意:
- 这只涉及"我想从月2日到月最后一天禁用"的第一点
- 并没有禁用"本月的第一天",因为我不知道如何才能做到这一点
Ext.create('Ext.form.Panel', {
renderTo: Ext.getBody(),
width: 300,
bodyPadding: 10,
title: 'Dates',
items: [{
xtype: 'datefield',
anchor: '100%',
fieldLabel: 'From',
name: 'from_date',
disabledDates: ['../02/..',
'../03/..',
'../04/..',
'../05/..',
'../06/..',
'../07/..',
'../08/..',
'../09/..',
'../10/..',
'../11/..',
'../12/..',
'../13/..',
'../14/..',
'../15/..',
'../16/..',
'../17/..',
'../18/..',
'../19/..',
'../20/..',
'../21/..',
'../22/..',
'../23/..',
'../24/..',
'../25/..',
'../26/..',
'../27/..',
'../28/..',
'../29/..',
'../30/..',
'../31/..'],
maxValue: new Date() // limited to the current date or prior
}]
});
<link href="http://cdn.sencha.com/ext/gpl/4.2.0/resources/css/ext-all.css" rel="stylesheet"/>
<script src="//cdn.sencha.io/ext-4.2.0-gpl/ext-all.js"></script>
尝试在视图中绑定disabledDates,并在控制器上使用setDisabledDates示例:
您的商品
{
xtype: 'datefield',
reference: 'date',
altFormats: 'd/m/Y',
bind:{
disabledDates :'{dateDisabled}'
}
}
您的控制器
dateDisabled: function () {
// your stuff
return // array with dates to desactivate
}
'02/..'
的意思是:"禁用所有包含02/和任意两个字符的日期。"您确定2015年2月8日没有被禁用吗?我的猜测是,整个二月都是残疾人。
虽然你可以创建一个正则表达式来表示"除第一天外的所有日子",但我不知道如何使用这个怪物:
disabledDates: ['^02', '^03', '^04', '^05', '^06', '^07', '^08', '^09', '^1', '^2', '^3', '01/03/2015']
但是,为了可用性,我建议使用不同的用户体验元素,因为你禁用了90%以上的日期。我想,两个组合框,一个用于月份,另一个用于年份,会更合适。