Handling Missing Cell Click Event in SfScheduler for .NET MAUI

Hi Syncfusion Team,

I'm currently working with the SfScheduler component in a .NET MAUI application and have encountered an issue where there doesn't appear to be a cell click event. I need to implement functionality that triggers when a user clicks on a specific cell within the scheduler.

The Tapped and SelectionChanged events do not work properly for my use case. My SfScheduler contains Appointments, and when I tap on an Appointment, the Date is null. I need to obtain the date from the tapped cell, regardless of whether the tap occurs on an empty cell or an Appointment.

Any code snippets, documentation links, or examples would be greatly appreciated. Thank you in advance for your help!


5 Replies

VM Vidyalakshmi Mani Syncfusion Team July 8, 2024 02:14 PM UTC

Hi Yaro,


Thank you for reaching out to us. Based on the information you've shared, we've reviewed your query. In the MAUI SfScheduler control when tapping on a cell in the scheduler, the date time of the cell can indeed be retrieved. However, when tapping on an appointment, only the start and end time of the appointment itself are accessible, resulting in a null value for the cell's date time. Here’s how you can obtain the start and end time of tapped appointment:


 

private void Scheduler_Tapped(object sender, Syncfusion.Maui.Scheduler.SchedulerTappedEventArgs e)

{

    var appointments = e.Appointments;

    if (appointments != null)

    {

        SchedulerAppointment appointment = (SchedulerAppointment)appointments.FirstOrDefault();

        if (appointment != null)

        {

            DateTime startTime = appointment.StartTime;

            DateTime endTime = appointment.EndTime;

        }

    }

}

 


This behavior is intentional to differentiate between interactions with cells and appointments within the scheduler.


To assist you further, could you please provide more details about your specific use case and why you need to retrieve the date time of the cell when tapping on an appointment? Understanding your requirements better will enable us to suggest the best approach to meet your needs effectively.


Regards,

Vidyalakshmi M.




YA Yaro July 9, 2024 08:46 AM UTC

Hello Vidyalakshmi.

Thank you for your reply.

However, in my case, I need the date of the cell I've tapped. Is it possible to improve it by adding an additional parameter, such as isAppointmentClicked and not null Date for the cell?

I only need the cell's date.



VM Vidyalakshmi Mani Syncfusion Team July 10, 2024 12:05 PM UTC

Hi Yaro,


To distinguish between a cell tap and an appointment tap in the Scheduler, you can use the Element property in the Tapped event. Here’s an example of how to implement this:


 

private void Scheduler_Tapped(object sender, SchedulerTappedEventArgs e)

{

    if (e.Element is SchedulerElement.SchedulerCell)

    {

      // Handle cell tap

    }

    else if (e.Element is SchedulerElement.Appointment)

    {

      // Handle appointment tap

    }

}

 


By checking the tapped element, you can determine whether it is a cell or an appointment and handle it accordingly. We have prepared a simple sample to demonstrate this functionality, which is attached for your reference.


If you have any questions or need further assistance, please let us know.


Regards,
Vidyalakshmi M.



Attachment: MauiScheduler_c36c15f7.zip


YA Yaro July 11, 2024 09:45 AM UTC

I would prefer not to have to tap on an appointment. Instead, I would like to be able to tap on a cell's date regardless of whether the cell contains an appointment or is empty.

Thank you.



VM Vidyalakshmi Mani Syncfusion Team July 16, 2024 10:59 AM UTC

Hi Yaro,


If an appointment spans from 9 AM to 11 AM, as shown in the image below, and you click within the 10 AM to 11 AM cell, the tap is detected as occurring on the appointment view itself. Therefore, the Tapped event will return the appointment's data, including its start and end times, rather than the cell's specific time.


customize-current-time-indicator-appearance-in-timeslots-views-in-maui-scheduler


To better assist you, could you please elaborate on your use case for wanting to retrieve the cell date when tapping on the appointment view? This information will help us provide a tailored solution that fits your requirements.


Regards,

Vidyalakshmi M.



Loader.
Up arrow icon