jquery datepicker每月和每年的行数和列数

时间:2017-09-19 20:32:14

标签: jquery twitter-bootstrap datepicker

我需要你保留这个3x4格式

http://www.eyecon.ro/bootstrap-datepicker/ - >将查看模式限制为几个月

This format

你可以从javascript配置它,还是应该从css完成?

$.fn.datepicker.dates['es'] = {
    days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
    monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
    today: "Today",
    clear: "Clear"      
};
$('.daterange-single-p').datepicker({ 
    autoclose: true,
    minViewMode: 1,
    language: "es-ES",
    format: 'mm-yyyy'
});

1 个答案:

答案 0 :(得分:0)

  

你可以从javascript配置它,还是应该从css完成?

您可以分两步配置:

  • viewMode 设置为2
  •   

    .datepicker('setValue', value):为datepicker设置一个新值。它可以是指定格式的字符串或Date对象。

第一个用于显示年份,第二个用于设置开始日期

$('.daterange-single-p').datepicker({
   autoclose: true,
   minViewMode: 1,
   language: "es",
   format: 'mm-yyyy',
   viewMode: 2
}).datepicker('setValue', '01-2020');

为了获得3行X 4列,您只需将以下内容添加到样式中:

.datepicker td span {
   width: 42px !important;
   margin-right: 0px !important;
   margin-left: 0px !important;
}



$.fn.datepicker.DPGlobal.dates['es'] = {
    days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
    daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
    months: ["Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"],
    monthsShort: ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"],
    today: "Today",
    clear: "Clear"
};
$('.daterange-single-p').datepicker({
    autoclose: true,
    minViewMode: 1,
    language: "es",
    format: 'mm-yyyy',
    viewMode: 2
}).datepicker('setValue', '01-2020');

.datepicker td span {
  width: 42px !important;
  margin-right: 0px !important;
  margin-left: 0px !important;
}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://rawgit.com/mskasal/bootstrap-datepicker/master/css/datepicker.css">
<script src="https://rawgit.com/mskasal/bootstrap-datepicker/master/js/bootstrap-datepicker.js"></script>

<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
    <input class="span2 daterange-single-p" size="16" type="text" value="12-02-2012">
    <span class="add-on"><i class="icon-th"></i></span>
</div>
&#13;
&#13;
&#13;