We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Pass parameter in OK Click method for SfDialog component

Hello, 

I am using SfDialog component  in Command Buttons for Delete and Cancel.

Please find enclosed my sample project. I have couple of questions

1)  I need to pass  a parameter i.e Job_id to OkClick method when the Ok button is clicked in the SfDialog component. With the Job_id I need to call a method to delete the data from the database. 

How do I accomplish passing Job_Id in the OkClick method

2) I am using the SfDialog component for both Delete and Cancel.  How does the SfDialog component know that the pop up is for Delete and Cancel

So for OkClick method I need to pass Job_Id and the status i.e Delete /Cancel etc. So that I can call separate methods for Delete and Cancel.

Any feedback and input will be helpful

Kapil 


Attachment: DialogBoxComponet_c602d288.zip

1 Reply

VY Vinothkumar Yuvaraj Syncfusion Team February 23, 2023 03:39 PM UTC

Hi Kapil,


Query 1 : ” I need to pass  a parameter i.e Job_id to OkClick method when the Ok button is clicked in the SfDialog component. With the Job_id I need to call a method to delete the data from the database. 


We recommend that you set the global variable to "Job-Id" when you press the delete key. This approach will enable you to retrieve the value of "Job-Id" from the global variable and pass it to the OkClick method, allowing you to delete data from the database.


@code {

public int JobIdDelete;

public int JobIdCancel;

 

public async void OnCommandClicked(CommandClickEventArgs<GetBasicAnalysisJobsForUser> args)

    {

    if (args.CommandColumn.ID == "Delete")

    {

       this.JobIdDelete = args.RowData.Job_Id;

    }

    if (args.CommandColumn.ID == "Cancel")

    {

       this.JobIdCancel = args.RowData.Job_Id;

    }

}



Query 2 : “I am using the SfDialog component for both Delete and Cancel.  How does the SfDialog component know that the pop up is for Delete and Cancel


To meet your requirements, we suggest using the following code, which should help the SfDialog component identify whether the popup is for Delete or Cancel.


public async void OnCommandClicked(CommandClickEventArgs<GetBasicAnalysisJobsForUser> args)

    {

    if (args.CommandColumn.ID == "Delete")

    {

       this.ButtonClick = args.CommandColumn.ID;

    }

}



Please see the attached sample for your reference.


Regards,

Vinothkumar


Attachment: DialogBoxComponet_65f32ef0_2839a65b.zip

Loader.
Up arrow icon