This is a migrated thread and some comments may be shown as answers.

add delete confirmation to AJAX-enabled Context Menu

2 Answers 25 Views
Menu
This is a migrated thread and some comments may be shown as answers.
lina fetisova
Top achievements
Rank 1
lina fetisova asked on 06 Aug 2010, 11:53 AM
Good day!
Can I add delete confirmation when I select "Delete" in such a menu?
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandmenu/defaultcs.aspx?product=menu

Is it possible to call to javascript function from such a C# code:
protected void RadMenu1_ItemClick(object sender, RadMenuEventArgs e)
        {
            int radGridClickedRowIndex;

            radGridClickedRowIndex = Convert.ToInt32(Request.Form["radGridClickedRowIndex"]);

            switch (e.Item.Text)
            {
                case "Edit":
                    RadGrid1.Items[radGridClickedRowIndex].Edit = true;
                    RadGrid1.Rebind();
                    break;
                case "Add":
                    RadGrid1.MasterTableView.IsItemInserted = true;
                    RadGrid1.Rebind();
                    break;
                case "Delete":
                    RadGrid1.MasterTableView.PerformDelete(RadGrid1.Items[radGridClickedRowIndex]);
                    break;
            }
        }

?

2 Answers, 1 is accepted

Sort by
0
Accepted
Cori
Top achievements
Rank 2
answered on 06 Aug 2010, 08:39 PM
Hello Lina,

To accomplish that you need to handle the OnClientItemClicking event. Like so:

function OnClientItemClicking(sender, args) {
            var item = args.get_item();
            if (item.get_text() == "Delete") {
                args.set_cancel(!confirm("Are you sure you want to delete?"));
            }
        }


I hope that helps.
0
lina fetisova
Top achievements
Rank 1
answered on 09 Aug 2010, 04:19 AM
thank you very much, Cori!
Tags
Menu
Asked by
lina fetisova
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
lina fetisova
Top achievements
Rank 1
Share this question
or