从详细信息页面删除后如何导航回列表页面?
How do I navigate back to list page after delete from detail page?
这是我的详细信息页面上的删除代码:
/// <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
});
}
});
};
您应该可以通过修改代码以使用 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();
});
});
});
}
});
这是我的详细信息页面上的删除代码:
/// <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
});
}
});
};
您应该可以通过修改代码以使用 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();
});
});
});
}
});