2017-01-23 211 views
0

这里是我的删除代码这是我的详细信息页面上:如何在从详细信息页面删除后导航回列表页面?

/// <reference path="~/GeneratedArtifacts/viewModel.js" /> 

myapp.ViewReceipt.DeleteReceipt_execute = function (screen) { 

    msls.showMessageBox("Are you sure you want to delete this record?", { 
     title: "Confirm Delete", 
     buttons: msls.MessageBoxButtons.okCancel 
    }) 
    .then(function (result) { 
     if (result === msls.MessageBoxResult.ok) { 
      screen.getReceipt().then(function (receipt) { 
       receipt.deleteEntity(); 
       //Save changes 
       myapp.applyChanges().then(null, function fail(e) { 
        // If error occurs, show the error. 
        msls.showMessageBox(e.message, { title: e.title }).then(function() { 
         // Discard Changes 
         screen.details.dataWorkspace.ApplicationData 
          .details.discardChanges(); 
        }); 
       }); 
       //navigate back to list page 
       this.window.location.href = '#/BrowseReceipts.lsml'; //this doesn't work for me 
      }); 
     } 
    }); 
}; 

回答

1

您应该能够通过修改代码以使用myapp.navigateBack()方法来实现这一目标。

此方法应该被执行,一旦applyChanges成功完成后,通过实现其的onComplete回调,如图以下经修订例如:

msls.showMessageBox("Are you sure you want to delete this record?", { 
    title: "Confirm Delete", 
    buttons: msls.MessageBoxButtons.okCancel 
}).then(function (result) { 
    if (result === msls.MessageBoxResult.ok) { 
     screen.getReceipt().then(function (receipt) { 
      receipt.deleteEntity(); 
      // Save changes 
      myapp.applyChanges().then(function onComplete() { 
       myapp.navigateBack(); 
      }, function fail(e) { 
       // If error occurs, show the error. 
       msls.showMessageBox(e.message, { title: e.title }).then(function() { 
        // Discard Changes 
        screen.details.dataWorkspace.ApplicationData.details.discardChanges(); 
       }); 
      }); 
     }); 
    } 
}); 
相关问题