OnBeforeCellRender optimization
9 years ago.
Hello Team,
I have worked on day pilot scheduler but I am stuck at OnBeforeCellRender this server side method because it's taking too much time(around 4-5 mins taking for loading) for render the events.
I have used this event for setting style to CSS according to data (color).I have also mentioned the code snippet for your reference. Please help us on this for optimization.
protected override void OnBeforeCellRender(BeforeCellRenderArgs e)
{
if (e.ResourceId == "0" || listavailability.Count == 0)
{
e.BackgroundColor = "#FFD9CC";
}
else
{
var data = listavailability.Where(x => DateTime.Parse(x.Date.ToString("yyyy-MM-dd ") + x.StartTime.TimeOfDay.ToString()) <= e.Start && DateTime.Parse(x.Date.ToString("yyyy-MM-dd ") + x.EndTime.TimeOfDay.ToString()) >= e.End && x.ClinicRoomId == Convert.ToInt32(e.ResourceId.Split(',')[2]) && x.TherapistId == Convert.ToInt32(e.ResourceId.Split(',')[0])).ToList();
if (data.Count > 0)
{
e.BackgroundColor = "#fff";
}
else
{
e.BackgroundColor = "#f0f0f0";
}
}
}
DayPilot