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

Disable and highlight days in timeline view

1 Answer 167 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 14 Jun 2012, 09:30 AM
I'm writing a booking system and am using the Winforms Scheduler control. Based on data provided from the database for each resource, I need to be able to disable and change the display certain days.

For instance, if a consultant (resource row in the Schedule) cannot work on a specific day, then this day for that consultant should be visibly shown to be unavailable (highlighted/dimmed/greyed-out) and any clicking in the day cell for that resource should not trigger any events (new/edit appointmnent, and no context menu)

Can this be done, and if so, how?

thanks
Karl

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 18 Jun 2012, 12:36 PM
Hi Karl,

Thank you for contacting us.

You can use the CellFormatting event to modify the Enabled property corresponding to a specified condition. The following code snippet demonstrates how to achieve this:
     Color[] colors = new Color[]{Color.LightBlue, Color.LightGreen, Color.LightYellow,
Color.Red, Color.Orange, Color.Pink, Color.Purple, Color.Peru, Color.PowderBlue};
 
     string[] names = new string[]{"Alan Smith", "Anne Dodsworth",
"Boyan Mastoni", "Richard Duncan", "Maria Shnaider"};
 
     public Form82()
     {
         InitializeComponent();
 
         for (int i = 0; i < names.Length; i++)
         {
             Resource resource = new Resource();
             resource.Id = new EventId(i);
             resource.Name = names[i];
             resource.Color = colors[i];
 
             this.radScheduler1.Resources.Add(resource);
         }
 
         this.radScheduler1.CellFormatting += new EventHandler<Telerik.WinControls.UI.SchedulerCellEventArgs>(radScheduler1_CellFormatting);
         this.radScheduler1.GroupType = GroupType.Resource;
     }
 
     void radScheduler1_CellFormatting(object sender, Telerik.WinControls.UI.SchedulerCellEventArgs e)
     {
         if (e.CellElement is SchedulerHeaderCellElement) return;
         IResource res = e.CellElement.View.GetResources() != null ? e.CellElement.View.GetResources()[0] : null;
         DateTime date = e.CellElement.Date;
          
         if (res != null && !IsAvailable(res, date))
         {
             e.CellElement.Enabled = false;
         }
         else
         {
             e.CellElement.Enabled = true;
         }
     }
 
     private bool IsAvailable(IResource res, DateTime date)
     {
         return date.Day % 2 == 0;
     }

I hope this will help you. Do not hesitate to write back if you have any further questions.

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