2017-01-23 82 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(); 
       }); 
      }); 
     }); 
    } 
}); 
相關問題