This is a migrated thread and some comments may be shown as answers.

changing the background color of the time blocks on the scheduler

7 Answers 332 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 30 Mar 2011, 06:33 PM
I was wondering if there is any way that I would be able to manipulate the background of the scheduler screen for each time block under each resource.
I would like to have two primary colors, smiler to the working time that is currently in place but instead of one time range of 7 - 5 across all resources I would like for each resource to have its own multiple time range.

for example:

          |  Resource  1  |   Resource  2  |
4am   |                       |                         |
          |       blue         |         blue         |
5am   |                       |  ___________ |
          |                       |                         |
6am   |                       |                         |
          |___________ |       white          |
7am   |                       |                         |
          |       white        |                         |
8am   |                       |                         |
          |                       | ___________  |
9am   |                       |                         |
          |                       |        blue          |
10am |                       |                         |
          |                       | ___________  |
11am |                       |                         |
          |___________ |                         |
12pm |                       |       white          |
          |        blue        |                         |
 1pm  |                       |                         |
          |                       |                         |
2pm   |                       |                         |
          |                       |                         |
3pm   |                       |                         |
          |                       |                         |
4pm   |                       | ___________  |
          |                       |                        |
5pm   |                       |                        |
          |                       |       blue          |
6pm   |                       |                        |
          |                       |___________  |
7pm   |                       |                         |
          |                       |                         |
8pm   |                       |                         |
          |                       |                         |
9pm   |                       |                         |
          |                       |        white         |
10pm |                       |                         |
          |                       |                         |
11pm |                       |                         |
          |                      |                          |
12am |                       |                         |

so each resource could have basically there own multiple different working times, with different colors.

7 Answers, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 04 Apr 2011, 03:46 PM
Hello Andrew,

Currently, such customization abilities are not supported by RadScheduler although we have plans to extend this functionality in the future. I have created a PITS item so you can vote for it. If more people vote for it, we will increase its priority. You can find the PITS item here.

If you have any additional questions, feel free to ask.

Kind regards,
Ivan Todorov
the Telerik team
0
Andrew
Top achievements
Rank 1
answered on 04 Apr 2011, 04:03 PM
ok thank you,

Would it be possible earlier while we wait for that feature to become of a higher priority to make a function for example "SchedulerDayViewGroupedByResourceElement.SetCellsOpacity" overriadable and then I can do the work in our code for the time being.
0
Accepted
Sean Overman
Top achievements
Rank 1
answered on 04 Apr 2011, 05:55 PM
I too faced this problem.  I figured out a solution.

You need to write your own method to figure out if a "resource" is available at a certain time -- IsEmployeeScheduled(int, datetime) in my case.


if (Scheduler.ActiveViewType == SchedulerViewType.Day || Scheduler.ActiveViewType == SchedulerViewType.Week) {
    List<SchedulerDayViewElement> dayViews = null;
    //not sure why, but in weekview, the ViewElement is still of type "DayViewElement", so this cast is fine
    if (Scheduler.GroupType == GroupType.Resource) {
        dayViews = ((SchedulerDayViewGroupedByResourceElement)Scheduler.SchedulerElement.ViewElement).GetDayViewElements();
    } else {
        dayViews.Add((SchedulerDayViewElement)Scheduler.SchedulerElement.ViewElement);
    }
 
    foreach (SchedulerDayViewElement dve in dayViews) {
        int empID = (int)dve.View.GetResources()[0].Id.KeyValue;
 
        foreach (SchedulerCellElement sce in dve.DataAreaElement.Table.GetCells()) {
            if (IsEmployeeScheduled(empID, sce.Date)) {
                sce.BackColor = Color.FromArgb(230, 230, 230);
            } else {
                sce.BackColor = _unavailableColor;
            }
        }
    }
}


Telerik, can you tell me why the WeekView mode ViewElement is still of a DayViewElement type?

Thanks and I hope this helps.
0
Andrew
Top achievements
Rank 1
answered on 05 Apr 2011, 07:45 PM
that worked great thank you.
0
Ivan Todorov
Telerik team
answered on 07 Apr 2011, 09:42 AM
Hello Sean,

Thank you for sharing your approach with us.

In regards to your question, WeekView's view element is still of DayViewElement type because both views have the same functionality, just the range is different.

Your Telerik points have been updated for your community effort.

@Andrew:
I am glad you have found a solution

If you have any further questions, do not hesitate to ask.

All the best,
Ivan Todorov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andrew
Top achievements
Rank 1
answered on 09 Apr 2012, 12:41 PM
has there been any changes to the functionality that would cause the background colors to reset when scrolling left to right. this process works great but when I scroll left to view the other items all customized background colors change to there default color.  Or would it be a requirement to set the color as you scroll. 

As a side note we did try to register to try to find out what might have changed the value;
 - LayoutUpdated
 - PropertyChanged
 - RadPropertyChanged

the first time we scroll or go into the calendar the events fire, but after we scrolled once the events get unregistered and the colors get reverted, would there any suggestion to prevent this from occurring.

we dont recall seeing this issue when we first implemented the color changing events, so it could possibly be from a upgrade we are now on 2012.1.301, or we could have missed it.

Thank you
0
Ivan Todorov
Telerik team
answered on 12 Apr 2012, 12:26 PM
Hello Andrew,

I am not sure to which event you add the code that Sean posted. Generally, RadScheduler recycles its elements regularly and this might be the reason for loosing your handlers. However, with version 2012.1.301, you should be able to use the CellFormatting event for achieving this scenario:
this.radScheduler1.CellFormatting += new EventHandler<SchedulerCellEventArgs>(radScheduler1_CellFormatting);
this.radScheduler1.ActiveView = new SchedulerDayView();
 
void radScheduler1_CellFormatting(object sender, SchedulerCellEventArgs e)
{
    int empId = (int)e.CellElement.View.GetResources()[0].Id.KeyValue;
 
    if (IsEmployeeScheduled(empId, e.CellElement.Date))
    {
        e.CellElement.BackColor = Color.Red;
    }
    else
    {
        e.CellElement.ResetValue(SchedulerCellElement.BackColorProperty, ValueResetFlags.Local);
    }
}

Please note that in order to get it fired initially, you should change the view after you have subscribed to it.

I hope this will work for you.

Greetings,
Ivan Todorov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
Tags
Scheduler and Reminder
Asked by
Andrew
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Andrew
Top achievements
Rank 1
Sean Overman
Top achievements
Rank 1
Share this question
or