how to catch the SAVE and CANCEL buttons clicked events

I have a custom form I use to build an event


I have those 2 built-in buttons at the bottom



(I added the VISIT) but those are the standard buttons

this is the code that runs when the popup closes.





Tried as i can, I dont know which of the 2 buttons was clicked and I will like to be able to know if user clicked SAVE or CANCEL.


How can I know the caller ?


3 Replies

RM Ruksar Moosa Sait Syncfusion Team September 13, 2022 03:04 PM UTC

Hi Frederic,


We have checked on your query and suspect you use custom dialog at you end. Hence we have added a custom dialog in OnCellClick event of the scheduler and have added separate handlers from the Cancel and Save buttons like the below code. Kindly try the attached sample and let us know if you need any assistance.


<DialogButtons>

        <DialogButton Content="Save" IsPrimary="true" OnClick="@SaveClick" />

        <DialogButton Content="Cancel" OnClick="@CancelClick" />

    </DialogButtons>


private void CancelClick()

    {

        Console.WriteLine("Cancel clicked");

        this.IsVisible = false;

    }

    private void SaveClick()

    {

        Console.WriteLine("Save clicked");

        this.IsVisible = false;

    }


Output:

Graphical user interface, application

Description automatically generated


Regards,

Ruksar Moosa Sait


Attachment: BlazorScheduleCustomDialog_b5e043c0.zip


FR Frederic September 13, 2022 06:14 PM UTC

I use


Snippet
<ScheduleTemplates>
		<EditorTemplate>


RM Ruksar Moosa Sait Syncfusion Team September 14, 2022 02:57 PM UTC

Hi Frederic,


We have checked on your requirement and let you know that when the Save button is clicked, the OnActionBegin method triggers with args.ActionType as ActionType.EventCreate like highlighted in the below code snippet and you can get the appointment details in the args.AddedRecords. This method does not trigger when the Cancel button is clicked. Hence in this way you can differentiate the actions between the Save and Cancel buttons.


public void OnActionBegin(ActionEventArgs<AppointmentData> args)

    {

        if (args.ActionType == ActionType.EventCreate)

        {

            Console.WriteLine("Triggers when save is clicked");

        }

    }


Kindly try the attached sample and let us know if you need further assistance.


Regards,

Ruksar Moosa Sait


Attachment: BlazorScheduleSaveCancel_f9fea72b.zip

Loader.
Up arrow icon