Delete child item in dialog without refreshing parent

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

Viewing 0 reply threads
  • 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": "Delete item",
                  "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": "Error",
                              "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 5 years, 1 month ago by Alexander Bautz. Reason: Moved to correct forum
Viewing 0 reply threads
  • You must be logged in to reply to this topic.