在月视图中,如何在列标题中仅显示当前月份?
例如,这是7月的观点:
正如您所看到的,前4列仍显示6月(我猜它是因为视图中的前4天是在6月)。
我在String input = "The blue house Theatres";
input.replaceAll("\\bThe\\b", "AAA");
ddd, MMM YYYY
格式作为月份
答案 0 :(得分:0)
无法添加条件日期格式,因此这是最简单的方法。您检查存储在列标题中的日期,如果该日期是从上个月开始,则从标题中删除span元素。该函数在viewRender中定义:在fullCalendar初始化中。
viewRender: function() {
var daysOfWeek = [];
var tableHeaders = [];
//collect all table headers
$(".fc-chrono th").each(function() {
daysOfWeek.push(moment(this.attr("data-date")).get('date')); //store day, like 31
tableHeaders.push(this); //store element
});
//check if the border between month is somewhere here
var isBetweenTwoMonths = false;
var locationOfMonthBorder = null;
for (var i = 0; i < daysOfWeek.length - 1; i++) {
if (daysOfWeek[i] > daysOfWeek[i+1]) { // e.g. 31 > 1
isBetweenTwoMonths = true;
locationOfMonthBorder = i;
break;
}
}
//now remove all the column header texts up to the first day of next month
if (isBetweenTwoMonths) {
for (var i = 0; i < locationOfMonthBorder + 1; i++) {
tableHeaders[i].find("span.fc-cell-text").remove();
}
}
}