_UserGridPartial.cshtml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. @model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Admin.User.UserDataModel>
  2. <script>
  3. function editUser(id) {
  4. if (!id) return;
  5. $(".userEditPopupContainer").remove();
  6. $.ajax({
  7. url: '@Url.Action("EditUser", "Admin")',
  8. data: { Id: id },
  9. success: function (response) {
  10. $("body").append(response);
  11. },
  12. error: function () {
  13. alert("error occured");
  14. }
  15. });
  16. }
  17. </script>
  18. @Html.DevExpress().GridView(
  19. settings =>
  20. {
  21. settings.Name = "devGridViewUser";
  22. settings.KeyFieldName = "ID";
  23. settings.CallbackRouteValues = new { Controller = "Admin", Action = "ViewUsers" };
  24. settings.Width = Unit.Percentage(100);
  25. settings.Columns.Add(column => {
  26. column.Caption = "#";
  27. column.SetDataItemTemplateContent(c =>
  28. {
  29. ViewContext.Writer.Write(
  30. "<a href=\"#\" onclick=\"editUser(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Bearbeiten</a>&nbsp;" +
  31. Html.ActionLink("Löschen", "",
  32. new { Id = DataBinder.Eval(c.DataItem, "Id") },
  33. new { onclick = "return confirm('Möchten Sie den Benutzer wirklich löschen?')" })
  34. );
  35. });
  36. column.SetHeaderTemplateContent(c =>
  37. {
  38. ViewContext.Writer.Write(
  39. "<a href=\"#\" onclick=\"editUser(-1)\">Neu</a>&nbsp;");
  40. });
  41. column.Settings.AllowDragDrop = DefaultBoolean.False;
  42. column.Settings.AllowSort = DefaultBoolean.False;
  43. column.Width = 70;
  44. });
  45. settings.Columns.Add("Forename");
  46. settings.Columns.Add("Lastname");
  47. settings.Columns.Add("MailAddress");
  48. //settings.Columns.Add(column => {
  49. // column.FieldName = "CategoryID";
  50. // column.Caption = "Category";
  51. // column.ColumnType = MVCxGridViewColumnType.ComboBox;
  52. // var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
  53. // comboBoxProperties.DataSource = NorthwindDataProvider.GetCategories();
  54. // comboBoxProperties.TextField = "CategoryName";
  55. // comboBoxProperties.ValueField = "CategoryID";
  56. // comboBoxProperties.ValueType = typeof(int);
  57. //});
  58. settings.ClientLayout = (s, e) =>
  59. {
  60. if(e.LayoutMode == ClientLayoutMode.Loading) {
  61. if(Session["UserGridState"] != null)
  62. e.LayoutData = (string)Session["UserGridState"];
  63. }
  64. else
  65. Session["UserGridState"] = e.LayoutData;
  66. };
  67. }).Bind(Model).GetHtml()