Cannot convert from

So I used this example to get CRUD editing with your Scheduler tool

Blazor Scheduler External Form Editing Example - Syncfusion Demos , but I get this error:

Argument 2: cannot convert from 'method group' to 'EventCallback' 

Here is my markup code:

  <SfSchedule TValue="VwCalendarItemsSlim" Height="650px" SelectedDate="@(CurrentDate)">

               <ScheduleEvents TValue="VwCalendarItemsSlim" OnEventDoubleClick="OnEventDoubleClick" OnEventClick="OnEventClick" OnCellClick="OnCellClick" OnCellDoubleClick="OnCellDoubleClick"></ScheduleEvents>

                <ScheduleEventSettings DataSource="@DataSource">

                    <ScheduleField Id="MatterEventId">

                        <FieldSubject Name="Subject"></FieldSubject>

                        <FieldStartTime Name="StartDate"></FieldStartTime>

                        <FieldEndTime Name="EndDate"></FieldEndTime>

                        <FieldIsAllDay Name="IsAllDay"></FieldIsAllDay>

                        <FieldStartTimezone Name="TimeZone"></FieldStartTimezone>

                        <FieldRecurrenceRule Name="RecurrenceInfo"></FieldRecurrenceRule>

                        <FieldLocation Name="Location"></FieldLocation>

                        <FieldDescription Name="EventDescription"></FieldDescription>

                    </ScheduleField>

                </ScheduleEventSettings>

                <ScheduleTimeScale Interval="60" SlotCount="6"></ScheduleTimeScale>

                <ScheduleViews>

                    <ScheduleView Option="View.Day"></ScheduleView>

                    <ScheduleView Option="View.Week"></ScheduleView>

                    <ScheduleView Option="View.WorkWeek"></ScheduleView>

                    <ScheduleView Option="View.Month"></ScheduleView>

                    <ScheduleView Option="View.Agenda"></ScheduleView>

                </ScheduleViews>

            </SfSchedule>

and the code to go with it:

  private async Task OnSave()

    {

        if (isCellClick)

        {

            //await this.Schedule.AddEvent(SelectedData);

            CalendarService.InsertUpdateOrDelete(SelectedData);

            isCellClick = false;

        }

        else

        {

            //await this.Schedule.SaveEvent(SelectedData);

            CalendarService.InsertUpdateOrDelete(SelectedData);

        }

    }

    private void OnCancel()

    {

        SelectedData = new MatterEvent()

        {

            EventDateAssigned = new DateTime(2020, 1, 10, 9, 0, 0),

            EventCompletionDate = new DateTime(2020, 1, 10, 10, 0, 0),

            Subject = "Add title"

        };

    }

    private void OnEventClick(EventClickArgs<MatterEvent> args)

    {

        args.Cancel = true;

        SelectedData = args.Event;

    }

    private void OnEventDoubleClick(EventClickArgs<MatterEvent> args)

    {

        args.Cancel = true;

    }

    private async Task OnCellClick(CellClickEventArgs args)

    {

        args.Cancel = isCellClick = true;

        SelectedData = new MatterEvent();

        //SelectedData.Id = await this.Schedule.GetMaxEventId<int>();

        //SelectedData.EventDateAssigned = args.EventDateAssigned;

        //SelectedData.EventCompletionDate = args.EndTime;

        //SelectedData.Subject = args.Subject;

        //SelectedData.Location = args.Location;

    }

    private void OnCellDoubleClick(CellClickEventArgs args)

    {

        args.Cancel = true;

    }

I also note that the OnCellClick event doesn't seem to contain the selected appointment.  MatterEvent is the database model that I use for Appointments.

TIA,



1 Reply

NR Nevitha Ravi Syncfusion Team June 28, 2021 07:21 AM UTC

Hi Miles, 

Greetings from Syncfusion Support. 

We have checked your shared code and let you know that the issue might be due to not mapping proper fields for the appointments. We have prepared a sample for your reference which can be downloaded from the following link. 

    public AppointmentData SelectedData = new AppointmentData() { StartDate = new DateTime(2020, 1, 10, 9, 0, 0), EndDate = new DateTime(2020, 1, 10, 10, 0, 0) }; 
 
    private async Task OnCellClick(CellClickEventArgs args) 
    { 
        args.Cancel = isCellClick = true; 
        SelectedData = new AppointmentData(); 
        SelectedData.MatterEventId = await this.Schedule.GetMaxEventId<int>(); 
        SelectedData.StartDate = args.StartTime; 
        SelectedData.EndDate = args.EndTime; 
        SelectedData.Subject = "Add title"; 
        SelectedData.Location = null; 
    } 

Also the event OnCellClick will not contain data as appointment model, it will have CellClickEventArgs type which need to be converted to your appointment model type in the OnCellClick event handler as in the above code. Kindly make sure you are using the same field name in the database and scheduler model. Please try the above sample and let us know if you need any further assistance. 

Regards, 
Nevitha 


Loader.
Up arrow icon