Delete confirmation

Sep 9, 2011 at 7:17 PM

What is the way to add Delete Confirmation box on deleting a treeview node?

Coordinator
Sep 9, 2011 at 8:23 PM

You have to define a custom delete button tha calls your js function that ask for the confirmation and then calls the normals js function to delete a node.

The simplest way  to redefine a delete button is by using a manipulation button:

private static string customRemoveButtonScript = "MvcControlsToolkit_TreeView_CustomDelete(\"{0}\");";

public static MvcHtmlString MyCustomTreeViewDeleteButton<VM>(
            this HtmlHelper<VM> htmlHelper,
            string textOrUrl,
             ManipulationButtonStyle manipulationButtonStyle = ManipulationButtonStyle.Button,
            IDictionary<string, object> htmlAttributes = null,
            string name = null)
        {
            
            
            string id = htmlHelper.PrefixedId("Container");
            return htmlHelper.ManipulationButton(ManipulationButtonType.Custom, textOrUrl,
                                  string.Format(customRemoveButtonScript, id), name == null ? id + "_RemoveButton" : name, manipulationButtonStyle, htmlAttributes);
        }

Then define your js function MvcControlsToolkit_TreeView_CustomDelete:

function  MvcControlsToolkit_TreeView_CustomDelete(nodeRootId){

.......

//call standard delete to perform deletion

MvcControlsToolkit_TreeView_Delete(nodeRootId);

.......

}

Sep 10, 2011 at 1:51 AM

Excellent!

Thank you!