2016-04-26 53 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