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

Find Appointment/Resource

3 Answers 40 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Sergey
Top achievements
Rank 1
Sergey asked on 29 Jun 2012, 12:51 PM

How can you do the following programmatically?

Scenario A:

  1. scroll the view to the specified appointment,
  2. center view on it,
  3. animate appointment to highlight it.

Scenario B:

  1. do the same with resource.

3 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 04 Jul 2012, 07:29 AM
Hi Sergey,

RadScheduleView provides a way to scroll to certain appointment/resource using its ScrollIntoView method.

ScrollIntoView method can have one or two parameters, the first parameter should be appointment or slot, the second parameter is optional and defines whether the appointment/slot should be scrolled to the beginning of the view.

Such kind of animation of appointment/resource is not provided out of the box.

Kind regards,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Véronique
Top achievements
Rank 1
answered on 25 Jul 2019, 07:40 PM

Hello,

I would like to do the same animation ie highlight an appointment by programmation.

Is it still impossible or is there a way to do it ?

Thanks

Véronique

0
Vladimir Stoyanov
Telerik team
answered on 29 Jul 2019, 01:49 PM
Hello Véronique,

In order to highlight a particular appointment, you can change the Background of a Border inside the ControlTemplate of the AppointmentItem. Note, that the border will be different depending on the state of the item (for example, if it is selected). This is due to the fact that there are different borders inside the ControlTemplate for the different visual states.

Additionally, since the ControlTemplate is different for older themes vs newer themes you will have to target a different Border element depending on which theme you are using. Here is some sample code demonstrating what I have in mind:
// Find the AppointmentItem visual element depending on the Subject of the appointment.
// this.ScheduleView refers to the RadScheduleView instance
            var appointmentItem = this.ScheduleView.ChildrenOfType<AppointmentItem>().FirstOrDefault(app => (app.DataContext as AppointmentItemProxy).Subject == "First Appointment");
            Border border;
            Brush defaultBrush;
 
            // Older themes approach
            if (appointmentItem.IsSelected)
            {
                border = appointmentItem.ChildrenOfType<Border>().FirstOrDefault(b => b.Name == "CommonStatesVisual");
                var innerBorder = border.ChildrenOfType<Border>().FirstOrDefault();
 
                innerBorder.Background = Brushes.Red;
 
                this.ReturnBrushToBorder(innerBorder, null);
            }
            else
            {
                defaultBrush = appointmentItem.Background;
                appointmentItem.Background = Brushes.Red;
                this.ReturnBrushToItem(appointmentItem, defaultBrush);
            }
 
 
 
            // Newer themes approach
            //if (appointmentItem.IsSelected)
            //{
            //    border = appointmentItem.ChildrenOfType<Border>().FirstOrDefault(b => b.Name == "SelectionVisual");
            //    defaultBrush = border.Background;
 
            //    border.Background = Brushes.Red;
            //    this.ReturnBrushToBorder(border, defaultBrush);
            //}
            //else
            //{
            //    defaultBrush = appointmentItem.Background;
            //    appointmentItem.Background = Brushes.Red;
            //    this.ReturnBrushToItem(appointmentItem, defaultBrush);
            //}
 
     public void ReturnBrushToBorder(Border border, Brush defaultBrush)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
 
            timer.Tick += (s, args) => { border.Background = defaultBrush; };
            timer.Start();
        }
 
        public void ReturnBrushToItem(AppointmentItem item, Brush defaultBrush)
        {
            DispatcherTimer timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(1);
 
            timer.Tick += (s, args) => { item.Background = defaultBrush; };
            timer.Start();
        }

Please, give this approach a try and let me know how it goes.

Regards,
Vladimir Stoyanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ScheduleView
Asked by
Sergey
Top achievements
Rank 1
Answers by
Yana
Telerik team
Véronique
Top achievements
Rank 1
Vladimir Stoyanov
Telerik team
Share this question
or