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

Appointment Summary In MonthItemTemplate For Multiple Resources

4 Answers 113 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Anthony
Top achievements
Rank 1
Veteran
Anthony asked on 16 Nov 2017, 12:28 AM

Hi,

I am trying to show the number of appointments for any given day on the month view using the MonthItemTemplate. The schedule contains multiple resources.

The suggestion at https://www.telerik.com/forums/number-of-appointments-per-day does not work because the TimeRulerItemProxy I can pass to a MultiBindingConverter does not have any idea of the resource it belongs to.

Is there a way to get the resource so that I can tally the appointments for the resource on any given day?

Regards

Anthony

4 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 20 Nov 2017, 11:47 AM
Hello Anthony,

I'm attaching a sample project based on the forum thread you've referenced which seems to provide the desired result. For the purpose, I've used the AppointmentsSource property of the RadScheduleView control and checked how many appointments have the same date as the current TimeRulerItemProxy's one.

Please have a look and let me know if such an approach would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Anthony
Top achievements
Rank 1
Veteran
answered on 20 Nov 2017, 08:43 PM

Hi,

This approach does not work because it is not considering the different resources. I need to show a separate tally per day per resource.

Thanks

Anthony

0
Accepted
Dilyan Traykov
Telerik team
answered on 22 Nov 2017, 12:16 PM
Hello Anthony,

To also take the resources of the appointment into account, you will need to pass the DataContext of the TimeRulerItem to get ahold of its resources. This can be done in the following manner:

              <MultiBinding Converter="{StaticResource TimeRulerToAppointmentCountConverter}">
                  <Binding Path="DateTime" />
                  <Binding Path="AppointmentsSource"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:RadScheduleView}}" />
                  <Binding Path="DataContext"
RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType={x:Type telerik:TimeRulerItem}}" />
              </MultiBinding>

public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
    if (values.Length != 3)
        throw new TargetParameterCountException("TimeRulerToAppointmentCountConverter expects two parameters.");
    if (!(values[0] is DateTime) || !(values[1] is IList<Appointment>) || !(values[2] is GroupHeader))
        return String.Empty;
 
    var date = (DateTime) values[0];
    var items = values[1] as IList<Appointment>;
    var rulerGroup = values[2] as GroupHeader;
    var resource = rulerGroup.ParentKeys.Last() as IResource; // you may need to modify this logic if you have multiple resource types
    var resourceName = resource.ResourceName;
    var count = items.Where(a => a.Start.Date == date && a.Resources.Any(r => r.ResourceName == resourceName)).Count();
    return count.ToString();
}

Please let me know if this works for you.

Regards,
Dilyan Traykov
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Anthony
Top achievements
Rank 1
Veteran
answered on 22 Nov 2017, 10:08 PM

Hi Dilyan,

That works great. I just needed to change the IList to an IEnumerable as my AppointmentSource was an ObservableCollection.

Thanks for your help.

Regards

Anthony

Tags
ScheduleView
Asked by
Anthony
Top achievements
Rank 1
Veteran
Answers by
Dilyan Traykov
Telerik team
Anthony
Top achievements
Rank 1
Veteran
Share this question
or