事件的颜色没有正确显示,我在很多方面尝试过它,包括eventSources。我试图通过固定代码更改它,但结果仍然与下图相同。
颜色是从数据库动态获取的,这是请求的结果:
allDay: false
backgroundColor: "#00ff00"
color: "#00ff00"
editable: false
title: "Administrative Team: Shift A"
start:"2018-01-01T09:00:00"
end: "2018-01-01T17:00:00"
以下是我尝试过的代码:
function GenerateSchedule(Preview) {
var events = [];
var JsonParam = ({
'DateFrom': $("#datefrom").datepicker('getDate'),
'DateTo': $("#dateto").datepicker('getDate'),
'Id': $("#Plan_Id option:selected").val(),
'GenerateSchedule': Preview
});
$.ajax({
url: '@Url.Action("GenerateSchedule", "SchedulerGenerator")',
type: "POST",
dataType: "json",
data: JSON.stringify({ model: JsonParam }),
contentType: "application/json; charset=utf-8",
success: function (result) {
Jdata = JSON.parse(result)
$.each(Jdata, function (i, v) {
events.push({
title: v.TeamName + ': ' + v.ShiftName,
start: v.PlannedDateIn,
end: v.PlannedDateOut,
allDay: false,
editable: false,
color: v.ShiftColor,
backgroundColor: v.ShiftColor,
eventColor: v.ShiftColor,
});
});
FullCalendar(events);
},
});
};
function FullCalendar(events) {
$('#full-calendar').fullCalendar('destroy');
$('#full-calendar').fullCalendar({
defaultDate: new Date(),
timeFormat: 'h (mm)a',
header: {
left: 'prev, next today',
center: 'title',
right: 'month, basicWeek, basicDay, agenda'
},
events: events,
});
}
提前致谢!
答案 0 :(得分:0)
为每个事件添加'className'。
events.push({
title: v.TeamName + ': ' + v.ShiftName,
start: v.PlannedDateIn,
end: v.PlannedDateOut,
className: 'event-class-style-name' });
答案 1 :(得分:0)
我所做的只是在事件颜色,backgroundColor和eventColor中添加了' +"!important" '因为有些东西覆盖了我的颜色。谢谢你的关注!