appointments not showing up when associate a resource

Hi,


I need to show on SfCalendar (timeline week view) every resource's appointment.


I have done many tests. First of all I've started to show appointments without any resource, and appointments (fetched from a server) were showing correctly.


Once I added the custom object CalendarDataResource (passing the appointment's list and the resource's list) to the resources field of SfCalendar, when reloading resource appears correctly, but linked appointments won't show anymore.


Keep in mind that I have correctly linked appointments to resource, setting resource's id to appointment resourceIds field.


P.S. I'm using custom dto object for Appointment, and since I need to access its data, I added it in CalendarDataSource


Here some code (totally not in order, just to show you how it is coded):

AppointmentCalendarResource object passed to SfCalendar

_resources =

        AppointmentCalendarSource(_appointmentCollection, _employeeCollection);


add employees to employeeCollection

void _elaborateCalendarResource() {

    _employeeCollection.add(CalendarSyncFusion.CalendarResource(

        id: widget.employee.id.toString(),

        displayName:

            "${widget.employee.firstName!} ${widget.employee.lastName!}",

        color: IridiMgmtTheme.darkMode.colorScheme.primary,

        image: LoadImage.getImageProvider(widget.employee.imagePath)));

  }


add custom AppointmentCalendar to appointmentCollection

_appointmentCollection.add(AppointmentCalendar(

          id: appointment.id.toString(),

          ids: [appointment.employee!.id!],

          eventName: subject,

          notes: notes,

          background: IridiMgmtTheme.darkMode.colorScheme.primary,

          from: start,

          to: end,

         //custom dto object passed as parameter appointment: appointment));


custom object AppointmentCalendar (SfCalendar appointment basically?)

class AppointmentCalendar {

  DateTime from;

  DateTime to;

  Object? id;

  Object? recurrenceId;

  String eventName;

  bool isAllDay;

  Color? background;

  String? fromZone;

  String? toZone;

  String? recurrenceRule;

  List<DateTime>? exceptionDates;

  String? notes;

  List<Object>? ids;

  Appointment appointment;


  AppointmentCalendar(

      {required this.from,

      required this.to,

      this.id,

      this.recurrenceId,

      this.eventName = '',

      this.isAllDay = false,

      this.background,

      this.exceptionDates,

      this.recurrenceRule,

      this.notes = '',

      this.ids,

      required this.appointment});

}


class AppointmentCalendarSource

    extends CalendarSyncFusion.CalendarDataSource<AppointmentCalendar> {

  AppointmentCalendarSource(List<AppointmentCalendar> source,

      List<CalendarSyncFusion.CalendarResource> resourceColl) {

    appointments = source;

    resources = resourceColl;

  }


  @override

  List<Object>? getResourceIds(int index) {

    return appointments![index].ids as List<Object>?;

  }


  @override

  DateTime getStartTime(int index) {

    return appointments![index].from as DateTime;

  }


  @override

  DateTime getEndTime(int index) {

    return appointments![index].to as DateTime;

  }


  @override

  Object? getId(int index) {

    return appointments![index].id as Object?;

  }


  @override

  Object? getRecurrenceId(int index) {

    return appointments![index].recurrenceId as Object?;

  }


  @override

  Color getColor(int index) {

    return appointments![index].background as Color;

  }


  @override

  List<DateTime>? getRecurrenceExceptionDates(int index) {

    return appointments![index].exceptionDates as List<DateTime>?;

  }


  @override

  String? getRecurrenceRule(int index) {

    return appointments![index].recurrenceRule;

  }


  @override

  String getSubject(int index) {

    return appointments![index].eventName as String;

  }


  @override

  bool isAllDay(int index) {

    return appointments![index].isAllDay as bool;

  }


  @override

  String getNotes(int index) {

    return appointments![index].notes as String;

  }


  @override

  AppointmentCalendar? convertAppointmentToObject(

      AppointmentCalendar? customData,

      CalendarSyncFusion.Appointment appointment) {

    // TODO: implement convertAppointmentToObject

    return AppointmentCalendar(

        from: appointment.startTime,

        to: appointment.endTime,

        eventName: appointment.subject,

        background: appointment.color,

        isAllDay: appointment.isAllDay,

        id: appointment.id,

        recurrenceRule: appointment.recurrenceRule,

        recurrenceId: appointment.recurrenceId,

        exceptionDates: appointment.recurrenceExceptionDates,

        ids: appointment.resourceIds,

        appointment: customData!.appointment);

  }

}


2 Replies 1 reply marked as answer

MK Muthulakshmi Kalaiselvan Syncfusion Team April 5, 2022 02:45 PM UTC

Hi,


Thank you for contacting Syncfusion support.


Based on provided information we have analyzed the mentioned issue “Appointments are not shown when associate with the resources”, we have ensured the reported issue. It is working fine as expected from our end.


Kindly find the modified sample by referring to the following link:

https://www.syncfusion.com/downloads/support/forum/174131/ze/resource_custom_appointment-112629671


Please check the sample and let us know.
If you are still facing the issue, could you please modify the shared sample to replicate the issue. So that we could analyze further and provide you with a possible solution at the earliest.


We hope that this helps you. Please let us know if you need further assistance.


Regards,

Muthulakshmi K


Marked as answer

SR Simone Ruvolo April 24, 2022 04:02 PM UTC

Hi,


thanks and sorry for late response.


The problem is solved, as I better follwed the provided example


Loader.
Up arrow icon