_SiteEditTreePartial.cshtml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. @{
  2. var userContext = GreenTree.Nachtragsmanagement.Core.CommonHelper.UserContext();
  3. }
  4. @model GreenTree.Nachtragsmanagement.Web.Models.Site.SiteDataModel
  5. @Html.DevExpress().TreeList(t =>
  6. {
  7. t.Name = "devTreeListSiteDeviationAppendices";
  8. t.KeyFieldName = "TreeKey";
  9. t.ParentFieldName = "TreeParentKey";
  10. t.CallbackRouteValues = new { Controller = "Site", Action = "PartialDeviationAppendices", siteId = Model.Id };
  11. t.Width = Unit.Percentage(100);
  12. t.Settings.GridLines = GridLines.Vertical;
  13. t.Columns.Add(column =>
  14. {
  15. column.Caption = "#";
  16. column.SetDataCellTemplateContent(c =>
  17. {
  18. var treeKey = DataBinder.Eval(c.DataItem, "TreeKey").ToString();
  19. if (treeKey == "a_0")
  20. {
  21. ViewContext.Writer.Write(
  22. "<a href=\"#\" onclick=\"addDeviationToSite(" + Model.Id + ")\">Neue VA</a><br />");
  23. }
  24. else if (treeKey.StartsWith("d"))
  25. {
  26. ViewContext.Writer.Write(
  27. "<a href=\"#\" onclick=\"editDeviation(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Bearbeiten</a>&nbsp;");
  28. ViewContext.Writer.Write(
  29. "<a href=\"#\" onclick=\"confirmDeleteDeviation(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Löschen</a>");
  30. }
  31. else if (treeKey.StartsWith("a"))
  32. {
  33. ViewContext.Writer.Write(
  34. "<a href=\"#\" onclick=\"addDeviationToAppendix(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Neue VA</a><br />");
  35. ViewContext.Writer.Write(
  36. "<a href=\"#\" onclick=\"editAppendix(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Bearbeiten</a>&nbsp;");
  37. ViewContext.Writer.Write(
  38. "<a href=\"#\" onclick=\"confirmDeleteAppendix(" + DataBinder.Eval(c.DataItem, "Id") + ")\">Löschen</a>");
  39. }
  40. });
  41. });
  42. t.Columns.Add(column =>
  43. {
  44. column.Caption = "Nummer";
  45. column.SetDataCellTemplateContent(c =>
  46. {
  47. var treeKey = DataBinder.Eval(c.DataItem, "TreeKey").ToString();
  48. if (treeKey.StartsWith("a"))
  49. {
  50. ViewContext.Writer.Write("<b>" + DataBinder.Eval(c.DataItem, "CustomNumber") + "</b>");
  51. }
  52. else if (treeKey.StartsWith("d"))
  53. {
  54. ViewContext.Writer.Write(DataBinder.Eval(c.DataItem, "CustomNumber"));
  55. }
  56. });
  57. });
  58. t.Columns.Add(column =>
  59. {
  60. column.FieldName = "Description";
  61. column.Caption = "Bezeichnung";
  62. column.CellStyle.Wrap = DefaultBoolean.True;
  63. });
  64. t.Columns.Add(column =>
  65. {
  66. column.Caption = "Eingang";
  67. column.FieldName = "ReceiptDate";
  68. column.PropertiesEdit.DisplayFormatString = "dd.MM.yyyy";
  69. });
  70. t.Columns.Add(column =>
  71. {
  72. column.Caption = "Bewertung";
  73. column.FieldName = "Value";
  74. column.PropertiesEdit.DisplayFormatString = "c2";
  75. });
  76. t.Columns.Add("StatusDescription", "Status");
  77. t.Columns.Add(column =>
  78. {
  79. column.FieldName = "DistCatDescription";
  80. column.Caption = "Kategorien";
  81. column.CellStyle.Wrap = DefaultBoolean.True;
  82. });
  83. t.Columns.Add(column =>
  84. {
  85. column.Caption = "Kommentar";
  86. column.CellStyle.Wrap = DefaultBoolean.True;
  87. column.SetDataCellTemplateContent(c =>
  88. {
  89. var id = Convert.ToInt32(DataBinder.Eval(c.DataItem, "Id"));
  90. var treeKey = DataBinder.Eval(c.DataItem, "TreeKey").ToString();
  91. var comment = DataBinder.Eval(c.DataItem, "Comment");
  92. var text = comment == null
  93. ? String.Empty
  94. : comment.ToString();
  95. if (text.ToString().Length > 40)
  96. {
  97. ViewContext.Writer.Write(text.Substring(0, 40) + " ...");
  98. if (treeKey.StartsWith("a"))
  99. ViewContext.Writer.Write("<a href=\"#\" onclick='showComment(\"appendix\"," + id + ",this)'><br />Anzeigen</a>");
  100. else
  101. ViewContext.Writer.Write("<a href=\"#\" onclick='showComment(\"appendix\"," + id + ",this)'><br />Anzeigen</a>");
  102. }
  103. else
  104. ViewContext.Writer.Write(text);
  105. });
  106. });
  107. t.ControlStyle.CssClass += "siteTreeList";
  108. t.Styles.IndentWithButton.Paddings.PaddingTop = new Unit(18, UnitType.Pixel);
  109. t.Styles.Cell.VerticalAlign = VerticalAlign.Top;
  110. t.Styles.Cell.Paddings.PaddingTop = new Unit(14, UnitType.Pixel);
  111. t.Styles.Cell.Paddings.PaddingBottom = new Unit(14, UnitType.Pixel);
  112. t.Styles.AlternatingNode.BackColor = System.Drawing.Color.FromArgb(247, 247, 247);
  113. }).Bind(Model.SiteTreeData).GetHtml()