Coloured Events Not Displaying in ASP.NET MVC

I am having problems displaying my events using different colours depending on event type. I have defined the different classes as follows:-

[code]var control_date = new Date(2011, 3, 20);
scheduler.templates.event_class = function (start, end, event) {

if (start < control_date) // event start before control date
	return "past_event";

if (event.subject) // assign special class when subject set
	return "event_" + event.subject;

return ""; // default event 

};[/code]

I have defined my event types as follows:-

var eventType = [ { key: '', label: 'Default Event' }, { key: 'outsideEvent', label: 'Non-Club Event' }, { key: 'meeting', label: 'Committee Meeting' }, { key: 'social', label: 'Club Social' }, { key: 'match', label: 'Club Match' } ];

I have the following CSS stored in dhtmlxscheduler.css for the meeting event type (the other event types have similar CSS):-

.dhx_cal_event.event_meeting div, .dhx_cal_event_line.event_meeting{ background-color: #add8e6 !important; color: #8b0000 !important; } .dhx_cal_event_clear.event_meeting{ color: #8b0000 !important; }

However, they are all being displayed in the default colours. What have I forgotten to do, or done wrong?

Hello,

Most likely

if (event.subject)

check is not passed and event receives default CSS. Make sure that in your case all events indeed have event.subject property.

Best regards,
Ilya

Hi Ilya

I made the mistake of naming the field on the database event_type not subject. I have changed the test in function init() to event.event_type and everything is now working. Thanks for your help.