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

How to get the calendar cells and change the background color from a specific Event?

Asked by SteaN
16 years ago.

How to get the calendar cells and change the calendar background colorfrom a specific Event?

so when Event takes: 9.00--10.00 am only this cells in the calendar should be colored red.
to start with:

protected void DayPilotCalendar1_BeforeEventRender(object sender, BeforeEventRenderEventArgs e)
{
if (e.Value != "")
{
if (e.Special)
{
e.DurationBarColor = SoortColor.Color2; //purple when special event
}

//1 get the timeperiod of the event.(e.end and e.start)
// 2 loopthrough the cells from this period in the calendar (??)
//3 if calendar is still yellow background in this periode, make it red background
(e.BackgroundColor = SoortColor.Color1;)

}
}

- where SoortColor.Color1 is a string of a color code
- the reason why I do it in this method because earlier i can't determine if the day is ''full'' of the events.

Can somebody help me with the 3 steps above?

Comment posted by SteaN
16 years ago.
no body ? :(
Comment posted by Dan Letecky
16 years ago.
I'm afraid that this is not an optimal solution. BeforeEventRender gets called before BeforeCellRender but it's not guaranteed (it may change in a future version).

I think the best solution would be to extract free/busy information from the database and check these values in BeforeCellRender.
  1. If you are able to extract pure free/busy time slots information the better (that means that overlapping events are joint into one busy block).
  2. You can also use the results of the query you are using to get the events. In this case it's useful to load it manually into a DataTable and use it for DataSource property and for the free/busy check (you will prevent double loading of the same data).
Comment posted by SteaN
16 years ago.

I understand your anwser, i will investigate the sequence "BeforeEventRender gets called before BeforeCellRender " in my code

to add more details:

- i load all the events, in a event there could be more then 1 connected user, if there are no other users left
the calendar has to be only red on that cells. on the above sequence i have to store somehow the information and use it in the cellrender event
- i render the calendar (all cells yellow, when there there is a possible way to make a event it is green)

if the event takes from 9.00-9.45 (3 calendar cells) there could be a way that only the 09.00-09.30 should be red en 9.30-.45 still green


Comment posted by SteaN
16 years ago.
Is it even possible to get calendar cells? (based on a time slot?)
Comment posted by Dan Letecky
16 years ago.
Is it even possible to get calendar cells? (based on a time slot?)

If you mean something like Cells collection, that's not possible. The cells are only available through BeforeCellRender event handler.

if the event takes from 9.00-9.45 (3 calendar cells) there could be a way that only the 09.00-09.30 should be red en 9.30-.45 still green

I see no problem with it. It's a matter of how you define an empty slot. You will have to either store the status for the individual cells in some collection and then use this collection in BeforeCellRender or you can compute it on the fly using the preloaded data (as I described earlier).
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.