TablePartial.cshtml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. @*
  2. For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
  3. *@
  4. @using SuperAdmin.Controllers;
  5. @using SuperAdmin.Models.View;
  6. @using SuperAdmin.Models.Object;
  7. @model TreeViewModel
  8. @{
  9. // get the newest data folowing by each service
  10. for (int j = 0; j < Model.rows.data.Count; j++)
  11. {
  12. RowStructure row = Model.rows.data[j];
  13. <tr class="@(j%2==0? "oven-column" : "")">
  14. <td class="text-truncate">@(j + 1)</td>
  15. <td class="text-truncate" style="max-width: 300px">@row.name_global</td>
  16. <td class="text-truncate">@UtilsController.GetStatus(row.is_show)</td>
  17. <td class="text-truncate">
  18. <img class="icon-style edit-btn" value="@row.id" src="~/img/icons8-edit-96.png" />
  19. <img class="icon-style delete-btn" value="@row.id" src="~/img/icons8-delete-bin-96.png" />
  20. </td>
  21. <td class="text-truncate">@row.update_date</td>
  22. </tr>
  23. }
  24. }
  25. <script>
  26. $('h4.title-parent-name').text('@(Model.parent != null ? Model.parent.name_global : "Categories")');
  27. $(".edit-btn").on("click", function () {
  28. var id = $(this).attr("value");
  29. console.log("edit id: ", id);
  30. $.ajax({
  31. type: "POST",
  32. url: urlConfig("/Tree/Editing"),
  33. headers: { 'RequestVerificationToken': $('input[name=__RequestVerificationToken]').val() },
  34. data: {
  35. "__RequestVerificationToken": $('input[name=__RequestVerificationToken]').val(),
  36. id: $(this).attr("value"),
  37. },
  38. success: function (data) {
  39. $('#contentModel').html(data);
  40. $('#myContent').modal({ "backdrop": "static", keyboard: true });
  41. $('#myContent').modal('show');
  42. },
  43. failure: function (data) {
  44. ///console.log(data);
  45. alert(data);
  46. },
  47. error: function (data) {
  48. ///console.log(data);
  49. alert(data);
  50. }
  51. });
  52. })
  53. $(".delete-btn").on("click", function () {
  54. var id = $(this).attr("value");
  55. console.log("delete id: ", id);
  56. var serviceName = $("#serviceName").val();
  57. $.ajax({
  58. type: "POST",
  59. url: urlConfig("/Partial/TreeConfirm"),
  60. data: {
  61. "message": "Are you sure ?",
  62. "id": id,
  63. "url": "/" + serviceName + "/DeletingAction"
  64. },
  65. success: function (data) {
  66. $('#informModel').html(data);
  67. $('#myInform').modal({ "backdrop": "static", keyboard: true });
  68. $('#myInform').modal('show');
  69. },
  70. failure: function (data) {
  71. ///console.log(data);
  72. alert(data);
  73. },
  74. error: function (data) {
  75. ///console.log(data);
  76. alert(data);
  77. }
  78. });
  79. })
  80. </script>