Delete child item in dialog without refreshing parent

Forums vLooup for SharePoint Delete child item in dialog without refreshing parent

This topic contains 0 replies, has 1 voice, and was last updated by  Alexander Bautz 2 months, 2 weeks ago.

  • Author
    Posts
  • #24200

    Alexander Bautz
    Keymaster

    If you open a child item from a parent form in EditForm-mode, deleting the child item will cause the parent (top) frame to reload, and you will loose any unsaved data. To work around this problem we need to override the default delete function with some Custom JS. Add this to the DispForm / EditForm of your child item:

    if(GetUrlKeyValue("IsDlg") === "1"){
        DeleteItemConfirmation = function(){
        	jQuery("#part1").css("visibility", "hidden");
            spjs.dffs.alert({
                "title": "SIMPLI",
                "msg": "Please confirm that you want to delete this item.",
                "ok": function () {
                    var dRes = spjs.utility.deleteItem({ "listName": _spPageContextInfo.pageListId, "id": spjs.dffs.data.thisItemID });
                    if (dRes.success) {
                        SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.Cancel);
                    } else {
                        spjs.dffs.alert({
                            "title": "SIMPLI",
                            "msg": "<span style='color:red;'>" + dRes.errorText + "</span>",
                            "ok": function () {
                                spjs.dffs.closeDlg();
                            }
                        });
                    }
                },
                "cancel": function () {
                    jQuery("#part1").css("visibility", "visible");
                    spjs.dffs.closeDlg();
                }
            });
        };
    }

    Alexander

    • This topic was modified 2 months, 2 weeks ago by  Alexander Bautz. Reason: Moved to correct forum

You must be logged in to reply to this topic.