beebul
September 12, 2015, 11:01pm
#1
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!
beebul
September 12, 2015, 11:02pm
#2
beebul
September 12, 2015, 11:33pm
#3
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.
beebul
September 13, 2015, 1:54am
#4
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?
beebul
September 13, 2015, 4:39am
#5
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.
screencast.com/t/TmMuxOQnkoBI
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
beebul
September 20, 2015, 10:51pm
#7
Thanks for the assistance. I managed to get this working through some changes to the database.