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

How to display warning icon in overlapping appointments?

7 Answers 166 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Divya
Top achievements
Rank 1
Divya asked on 09 Apr 2020, 02:02 PM

Hi,

 

I am using RadScheduleView for WPF. I have a requirement where I have to set a warning icon for overlapping appointments only. I tried with AppointmentItemContentTemplate="{StaticResource AppointmentTemplate}". However the icon gets displayed in all appointments. Is there any way to set style in such a way that only slots with multiple appointments have warning icon. Please help. 

Attaching the image.

7 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 13 Apr 2020, 01:19 PM

Hello Divya,

Thank you for the shared picture. 

You can use an AppointmentItemContentTemplateSelector to achieve the desired behavior. It allows you to show a different template depending on some custom logic. You can check whether there are multiple appointments in the same day and return a DataTemplate containing the warning icon. 

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Divya
Top achievements
Rank 1
answered on 13 Apr 2020, 02:11 PM

Hello Vladimir Stoyanov,

 

I doubt whether  AppointmentItemContentTemplateSelector will be useful. Because in my case , I have only 2 appointments. Both of them may be recurring. One will  be daily with 1 day gap and the other will be daily with 3 day gap. So at certain days they will definitely overlap. Such days has to be shown with warning icon. In short, we have to show warning for recurrence events inside an Appointment rather than for an Appointment. 

I had tried this with AppointmentItemContentTemplate earlier, but that led me to display icon in both the appointment object rather than the conflicting occurrences of that particular appointment. Please clarify.

 

Thanks,

Divya

0
Divya
Top achievements
Rank 1
answered on 15 Apr 2020, 07:28 AM

Hello Vladimir Stoyanov,

Please ignore my previous reply. I was able to achieve the functionality by implementing  the AppointmentItemContentTemplateSelector="{StaticResource CustomAppointmentTemplateSelector}"

This is the template style we have implemented.

public class CustomAppointmentTemplateStyle : ScheduleViewDataTemplateSelector
    {

     public DataTemplate DayAppointmentTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container, ViewDefinitionBase activeViewDefinition)
        {
            if (item is Occurrence && container is AppointmentItem)
            {
                var itemOcc = item as Occurrence;
                var rd = container.ParentOfType<RadScheduleView>();
                if (rd != null)
                {
                    ObservableCollection<Appointment> appointments;
                    if ((rd.DataContext as BackupSettingsViewModel) != null)
                    {
                        var viewModel = rd.DataContext as BackupSettingsViewModel;
                        appointments = viewModel.Appointments;
                    }                       
                    else
                    {
                        var viewModel = rd.DataContext as ArchivingSettingsViewModel;
                        appointments = viewModel.Appointments;
                    }
                    var appointments = (rd.DataContext as BackupSettingsViewModel).Appointments;
                    if (appointments.Any(x => x.Subject.Equals(itemOcc.Appointment.Subject.Equals(Properties.Resources.Backup) ? Properties.Resources.Archive : Properties.Resources.Backup)))
                    {
                        DateTime start = itemOcc.Start;
                        DateTime end = itemOcc.End;
                        var archapp = appointments.First(x => x.Subject.Equals(itemOcc.Appointment.Subject.Equals(Properties.Resources.Backup) ? Properties.Resources.Archive : Properties.Resources.Backup));
                        var occ = archapp.GetOccurrencesWithoutExceptionsFromDateTimeRange(start, end);
                        if (occ.Count > 0)
                            return this.DayAppointmentTemplate;
                    }
                }
            }

            return base.SelectTemplate(item, container, activeViewDefinition);
        }
    }

0
Divya
Top achievements
Rank 1
answered on 15 Apr 2020, 07:48 AM

However, in the above code, we are always getting  this value as null during the initial loading

var rd = container.ParentOfType<RadScheduleView>();

Say for ex: I have 2 appointments with recurrence pattern. During the first time loading of month view, the icon is displayed only in one recurrence event as seen in the image BeforeScroll.png, but after we scroll down to the bottom and again scroll to top, the warnings are displayed correctly as seen in AfterScroll.png. And the reason for this is the null value we get from  container.ParentOfType<RadScheduleView>();.

 

Please suggest what to do.

FYI: Sorry for posting this as another reply as my previous post got submitted and I am not able to edit / delete it.

 

Thanks,

Divya
                

0
Divya
Top achievements
Rank 1
answered on 15 Apr 2020, 07:53 AM

Continuation to my earlier post..

 

 

However, in the above code, we are always getting  this value as null during the initial loading
var rd = container.ParentOfType<RadScheduleView>();
Say for ex: I have 2 appointments with recurrence pattern. During the first time loading of month view, the icon is displayed only in one recurrence event as seen in the image BeforeScroll.png, but after we scroll down to the bottom and again scroll to top, the warnings are displayed correctly as seen in AfterScroll.png. And the reason for this is the null value we get from  container.ParentOfType<RadScheduleView>();.

Please suggest what to do.
FYI: Sorry for posting this as another reply as my previous post got submitted and I am not able to edit / delete it. ( Its really weird as we are not able to delete a post accidentally submitted. I think now there are multiple posts with same questions.)

Thanks,
Divya

0
Accepted
Vladimir Stoyanov
Telerik team
answered on 16 Apr 2020, 11:40 AM

Hello Divya,

I am glad to hear that you were able to achieve the desired result. 

As for the accessing the RadScheduleView with the ParentOfType extension method, I am assuming that initially the control is not yet loaded in the visual tree. That said, it seems that you are accessing the RadScheduleView in order to get the viewmodel from its DataContext and check the appointments collection. 

What I can suggest as an alternative is to to create a property inside the CustomAppointmentTemplateStyle class, which will hold the appointments collection instead. Then you can create the CustomAppointmentTemplateStyle object in code in a place where you also have access to the viewmodel and pass it the appointments. This way you would not need to wait for the RadScheduleView to load.

Regards,
Vladimir Stoyanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Divya
Top achievements
Rank 1
answered on 16 Apr 2020, 01:04 PM

Hi Vladimir Stoyanov.

I went on with you suggestion and it works well.

Thanks 

Divya.

Tags
General Discussions
Asked by
Divya
Top achievements
Rank 1
Answers by
Vladimir Stoyanov
Telerik team
Divya
Top achievements
Rank 1
Share this question
or