2016-04-26 52 views
0

版本:2.4.0FullCalendar月视图 - 1周隐藏日的数字(2周取消隐藏)

 $("#calendar").fullCalendar({ 
      height: 'auto', 
      header: { 
       left: '', 
       center: 'title', 
       right: '' 
      }, 
      views: { 
       agendaFourWeeks: { 
        type: 'month', 
        duration: { weeks: 1 }, 

        fixedWeekCount: false, 
        title: "HELLO", 
         } 
      }, 
      defaultView: 'agendaFourWeeks', 

     }); 
    }); 

上面的代码隐藏位于每个小区的右上角月份日数。如果您将周数更改为2(周:2),则会在右上角显示日数。我想显示1周的日期编号。

回答

1

发生了同样的问题,因为我试图在月视图中尽可能在第一天放置一个图标。

通过更新weekNumbers选项设置为true时创建的行中的单元格,找到了解决方案。这是在viewRender回调中完成的。

viewRender: function() { 
    // add the day date to the empty cells of the week number row 
    var i = 0; 
    var viewStart = $('#calendar').fullCalendar('getView').intervalStart; 
    $("#calendar").find('.fc-content-skeleton thead td:not(:nth-child(1))').empty().each(function(){ 
    $(this).append(moment(viewStart).add(i, 'days').format("D")); 
    i = i + 1; 
    }); 
}, 

然后样式匹配月视图

.fc-content-skeleton thead td { 
    text-align: right; 
    padding-right: 5px; 
    padding-top:2px; 
} 
.fc-week-number { 
    color: #bfbfbf; 
} 

实施例,因为这Fiddle 工作(使用moment.js库还)。

+0

感谢您的代码片段 - 你真棒! – Watson