首页 新闻 会员 周边

easyui时间插件,只显示年月,不显示日期,有人知道吗?

0
[已解决问题] 解决于 2016-10-08 11:03

easyui时间插件,只显示年月,不显示日期,有人知道吗?

雪剑残云的主页 雪剑残云 | 菜鸟二级 | 园豆:217
提问于:2016-09-07 17:14
< >
分享
最佳答案
0

jquery-ui-1.11.2

页面代码

<span id="HiddenDatePicker"><input autocomplete="off" type="text" id="BMonth" name="BMonth" value="" class="text textBorder" size="7" maxlength="7" onfocus="javascript:vDateType='4'" /></span>

JQUERY

$(document).ready(function () {
$('#BMonth').datepicker({
dateFormat: 'yy-mm',
dayNamesMin: ['日', '一', '二', '三', '四', '五', '六'],
monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
monthNamesShort: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
changeMonth: true,
changeYear: true,
constrainInput: true,
showButtonPanel: true,
closeText: '关闭',
currentText: '本月',
nextText: '下月',
prevText: '上月',
navigationAsDateFormat: true,
yearSuffix: '年',
showMonthAfterYear: true,
hideIfNoPrevNext: true,
yearRange: '1990:2030',
onChangeMonthYear: function (year, month, inst) {
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
},
beforeShow: function (input) {
$("#ui-datepicker-div").appendTo($("#HiddenDatePicker"));
},
autoclose: true,//选择后自动关闭
onClose: function (dateText, inst) {
var dateFileObj = $('#BMonth')[0];
var returnvalue = DateFormat(dateFileObj, dateFileObj.value, null, true, '4');
var dateFileYear = dateFileObj.value.split('-')[0];
var yearRange = $('#BMonth').datepicker('option', 'yearRange');
var yearRangeArr = yearRange.split(':');
if (dateFileYear == "" || inst.selectedYear < yearRangeArr[0] || inst.selectedYear > yearRangeArr[1]) {
$(this).datepicker('setDate', new Date());
}
else {
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
}
$("#HotelCode")[0].focus();
}
});
var _parseDate = $.datepicker.parseDate;//日期中不包含日的情况下,jq ui认为该日期非法,可以修改datepicker的ParseDate方法来绕过这个错误
$.datepicker.parseDate = function (format, value, settings) { 
DateFormat($('#BMonth')[0], $('#BMonth')[0].value, null, false, '4')
if (format == 'yy-mm')
return _parseDate.apply(this, ['yy-mm-dd', value + '-1', settings]);
else
return _parseDate.apply(this, arguments);
};
$('#BMonth').datepicker('setDate', new Date());
});

奖励园豆:5
Artikel | 菜鸟二级 |园豆:387 | 2016-09-14 16:08
其他回答(2)
0

easyui不知道,很流行的那个mydatepiker97,是根据format设置的,理论上easyui应该也有

顾晓北 | 园豆:10844 (专家六级) | 2016-09-07 17:32
0

  .datebox('setValue', year + '-' + month); //设置日期的值

wa-kaka | 园豆:272 (菜鸟二级) | 2016-09-12 08:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册