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
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));
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.
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]
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
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.
Thanks for the assistance. I managed to get this working through some changes to the database.