Categories.cshtml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. @{
  2. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  3. }
  4. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Appendix.CategoryDataModel>
  5. <script>
  6. var deleteId;
  7. function editCategory(id) {
  8. if (!id) return;
  9. $.ajax({
  10. url: '@Url.Action("EditCategory", "Appendix")',
  11. data: { Id: id },
  12. success: function (response) {
  13. setTimeout(function () {
  14. $(".categoryEditContainer").remove();
  15. $("body").append(response);
  16. }, 200);
  17. },
  18. error: function () {
  19. alert("error occured");
  20. }
  21. });
  22. }
  23. function confirmDelete(id) {
  24. if (!id) return;
  25. deleteId = id;
  26. $.ajax({
  27. type: "GET",
  28. url: '@Url.Action("GetCategory", "Appendix")',
  29. data: { Id: id },
  30. success: function (response) {
  31. if (response == "notFound") return;
  32. var category = JSON.parse(response);
  33. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteCategory);
  34. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{category}", category.Description));
  35. $(".dialogText").text($(".dialogText").text().replace("{category}", category.Description));
  36. popupControl.Show();
  37. }
  38. });
  39. }
  40. function deleteCategory() {
  41. $.ajax({
  42. type: "POST",
  43. url: '@Url.Action("DeleteCategory", "Appendix")',
  44. data: { Id: deleteId },
  45. success: function (response) {
  46. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteCategory);
  47. popupControl.Hide();
  48. setTimeout(function () {
  49. devGridViewCategory.PerformCallback();
  50. }, 200);
  51. },
  52. error: function () {
  53. alert("error occured");
  54. }
  55. });
  56. }
  57. </script>
  58. @Html.Partial("~/Views/Appendix/_CategoryListPartial.cshtml", Model)
  59. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  60. {
  61. PopupName = "devPopupControlDeleteCategory",
  62. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie die Kategorie \"{category}\" löschen möchten?</div>",
  63. HeaderText = "\"{category}\" löschen",
  64. YesFunction = "function (s, e) { deleteCategory(); }"
  65. })