View.cshtml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. @{
  2. Layout = "~/Views/Shared/_FunctionLayout.cshtml";
  3. }
  4. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Appendix.AppendixDataModel>
  5. <script>
  6. var deleteId;
  7. var gridScrollHeight;
  8. var gridScrollOffset = 240;
  9. var resizeFinished;
  10. $(document).ready(function () {
  11. gridScrollHeight = calculateGridScrollHeight();
  12. setTimeout(function () {
  13. devGridViewAppendix.PerformCallback();
  14. }, 500);
  15. });
  16. $(window).resize(function () {
  17. clearTimeout(window.resizedFinished);
  18. window.resizedFinished = setTimeout(function () {
  19. setGridScrollHeight();
  20. }, 250);
  21. });
  22. function calculateGridScrollHeight() {
  23. var windowHeight = $(window).height();
  24. var gridHeaderHeight = $("#devGridViewAppendix_DXHeadersRow0").height();
  25. var gridFooterHeight = $("#devGridViewAppendix_DXFooterRow").height();
  26. return windowHeight - gridHeaderHeight - gridFooterHeight - gridScrollOffset;
  27. }
  28. function setGridScrollHeight() {
  29. gridScrollHeight = calculateGridScrollHeight();
  30. devGridViewAppendix.PerformCallback();
  31. }
  32. function onToolbarItemClick(s, e) {
  33. if (!s || !e) return;
  34. if (IsExportToolbarCommand(e.item.name)) {
  35. $("#Format").val(e.item.name);
  36. $("#appendixExportForm").submit();
  37. } else if (e.item.name == "ToggleColumnChooser") {
  38. if (devGridViewAppendix.IsCustomizationWindowVisible())
  39. devGridViewAppendix.HideCustomizationWindow();
  40. else
  41. devGridViewAppendix.ShowCustomizationWindow();
  42. }
  43. }
  44. function IsExportToolbarCommand(command) {
  45. return command == "Pdf" || command == "Xlsx" || command == "Xls";
  46. }
  47. function editAppendix(id) {
  48. if (!id) return;
  49. $.ajax({
  50. url: '@Url.Action("EditAppendix", "Appendix")',
  51. data: { Id: id },
  52. success: function (response) {
  53. setTimeout(function () {
  54. $(".appendixEditContainer").remove();
  55. $("body").append(response);
  56. }, 200);
  57. },
  58. error: function () {
  59. alert("error occured");
  60. }
  61. });
  62. }
  63. function confirmDelete(id) {
  64. if (!id) return;
  65. deleteId = id;
  66. $.ajax({
  67. type: "GET",
  68. url: '@Url.Action("GetAppendix", "Appendix")',
  69. data: { Id: id },
  70. success: function (response) {
  71. if (response == "notFound") return;
  72. var appendix = JSON.parse(response);
  73. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  74. popupControl.SetHeaderText(popupControl.GetHeaderText().replace("{appendix}", appendix.CustomNumber));
  75. $(".dialogText").text($(".dialogText").text().replace("{appendix}", appendix.CustomNumber));
  76. popupControl.Show();
  77. }
  78. });
  79. }
  80. function deleteAppendix() {
  81. $.ajax({
  82. type: "POST",
  83. url: '@Url.Action("DeleteAppendix", "Appendix")',
  84. data: { Id: deleteId },
  85. success: function (response) {
  86. var popupControl = MVCxClientPopupControl.Cast(devPopupControlDeleteAppendix);
  87. popupControl.Hide();
  88. setTimeout(function () {
  89. devGridViewAppendix.PerformCallback();
  90. }, 200);
  91. },
  92. error: function () {
  93. alert("error occured");
  94. }
  95. });
  96. }
  97. </script>
  98. @using (Html.BeginForm("ExportPartialAppendices", "Appendix", FormMethod.Post, new { id = "appendixExportForm" }))
  99. {
  100. @Html.Hidden("Format")
  101. }
  102. @Html.Partial("~/Views/Appendices/_AppendixGridPartial.cshtml", Model)
  103. @Html.Partial("~/Views/Shared/_PopupDialogYesNo.cshtml", new GreenTree.Nachtragsmanagement.Web.Models.Global.YesNoDialogModel
  104. {
  105. PopupName = "devPopupControlDeleteAppendix",
  106. Content = "<div class='dialogText' style='padding: 12px'>Sind Sie sicher, dass Sie den Nachtrag \"{appendix}\" löschen möchten?</div>",
  107. HeaderText = "\"{appendix}\" löschen",
  108. YesFunction = "function (s, e) { deleteAppendix(); }"
  109. })