Change colour of recurring event based on database flag

When a user submits a timesheet for a recurring event I store a record in the table:

This is my current code but it’s colouring all events in the recurrence not just the single event in the pattern:

[code]public ContentResult Data()
{
int userId = Convert.ToInt32(Request.QueryString[“userid”]);
var helper = new DHXEventsHelper();

IEnumerable<UserSchedule> eventdata = _userSchedulerService.GetAllSchedulesForUser(userId);

var eventItems = eventdata.Select(eventItem => new EventModel
{                
    id = eventItem.Id,
    JobTitle = eventItem.Job.Name,
    start_date = eventItem.start_date,
    end_date = eventItem.end_date,
    JobId = (int)eventItem.JobId,
    ActivityId = eventItem.ActivityId,
    CostCentreId = eventItem.CostCentreId,
    UserId = (int)userId,
    rec_type = eventItem.rec_type,
    event_length = eventItem.event_length ?? null,
    event_pid = eventItem.event_pid,
    TimesheetNote = eventItem.TimesheetNote,
    color = eventItem.color,
    textColor = eventItem.textColor
}).ToList();

//Colour events
foreach (var eventItem in eventItems.Where(x => x.rec_type.Contains('#')))
{
    var relatedSchedules = _userSchedulerService.GetRelatedSchedules(eventItem.id).Where(x => x.TimesheetId != 0);

    var recurrings =
        helper.GetOccurrences(relatedSchedules, eventItem.start_date, eventItem.end_date);
    //var userSchedules = relatedSchedules as IList<UserSchedule> ?? relatedSchedules.ToList();
    foreach (UserSchedule recurring in recurrings)
    {
        eventItem.color = "grey";
    }
}
return (new SchedulerAjaxData(eventItems));

}[/code]

Thanks!

The image was truncated

http://i57.tinypic.com/2n0t3s9.jpg

And sorry I meant to say in the question, that I am trying to color events when a user submits a timesheet within a recurrence pattern.

Actually I realised that the data method just passes single events and recurrence pattern records to the view.

How do I access the colour of the event from the view with JavaScript?

So my database looks like this

The first row is the recurrence pattern, the second row is to store information about a timesheet that a user has made against the an event in the pattern.

So what I need is in the pattern, on the 14/09/2015 the occurrence is shaded in grey. Any advice is much appreciated. I think I will have to do this client side but not sure what method.

Direct link to image: [url]http://tinypic.com/r/2vx3kt2/8[/url]

Hello,
can you please show how it should look on the page? I’m not sure I completely understand.

When use modifies the event from the recurring series, the original instance is no longer shown
i.e.

  1. screencast.com/t/TmMuxOQnkoBI
  2. screencast.com/t/XNbL6xDuAPI
    So I’m not sure which event you want to color in gray.

However, you can define a JS template for event css class on the client side

docs.dhtmlx.com/scheduler/api__s … plate.html

The template function is called for each event that is being displayed in a scheduler, the event is passed as an argument. So you can inspect the event object and return a class that will color event gray, e.g.
docs.dhtmlx.com/scheduler/snippet/8a347e8b

Thanks for the assistance. I managed to get this working through some changes to the database.