search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Quick way to set background color of cells in DayPilotScheduler

Asked by Tony
29 days ago.

I am using a Scheduler on my application to show staff absences in a company across a given year and a client has asked if it is possible to shade the background color of cells based on the normal working days for a staff member (some staff work weekends, some don't). I have tried to do this using the BeforeCellRender event, passing a datatable of staff IDs and calendar days, with a 1 or 0 to denote whether it should be shown as a working day. However, with 200 staff showing over 365 days, it can take up to 45 seconds for the scheduler to show when trying to do this (whereas the scheduler is instant if that line of code is commented out).

Does anyone know of a faster mechanism, such as providing a bit pattern for an entire row, that would speed this process up?

Answer posted by Dan Letecky [DayPilot]
28 days ago.

The BeforeCellRender event is fired for every cell and it needs to be kept as efficient as possible. It is not possible to run a new database query in every invocation.

I recommend running a single query (e.g. in Page_Load) to get all the necessary data and storing the result in a special property of the WebForm page. In BeforeCellRender, only perform a simple in-memory lookup (within the data).

Comment posted by Tony
28 days ago.

HI Dan. Thanks for getting back to me. What I did was to create a simple datatable with three columns (resource ID, date and 1 or 0 to denote working day) and store that in memory, then in the BeforeCellRender event I run a select query on the datatable for resourceID and date, but that is still incredibly slow as there's tens of thousands of cells to populate. I just wondered if it possible at all to approach this in a more efficient way.

Comment posted by Dan Letecky [DayPilot]
28 days ago.

You can try to measure where the time is spent:

1. Database query and datatable creation.
2. Lookup. Instead of a datatable, it would be faster to use a hashtable with something like "resource_date" as a key. Searching an in-memory datatable with 70,000 rows can still take some time, especially if you repeat it 70,000 times.
3. Sending the data to the client. The data for 70,000 cells also need to be sent to the client side. The Scheduler tries to compress this data but the compression is based on finding rows/columns with same values which may not be your case. It will take some time to send this data to the client. You can try enabling gzip HTTP compression to make the transport faster.

New Reply
This reply is
or drop files here
Your name (optional):