@model IEnumerable<GreenTree.Nachtragsmanagement.Web.Models.Appendix.AppendixDataModel>

@using GreenTree.Nachtragsmanagement.Web.Extensions

@{ 
	var userContext = GreenTree.Nachtragsmanagement.Core.CommonHelper.UserContext();
}

@Html.DevExpress().GridView(Html.AppendixGridViewSettings()).Bind(Model).GetHtml()

@*@Html.DevExpress().GridView(s =>
{
	s.Name = "devGridViewAppendix";
	s.KeyFieldName = "Id";
	s.CallbackRouteValues = new { Controller = "Appendix", Action = "PartialAppendices" };
	s.Width = Unit.Percentage(100);
	s.Settings.ShowFilterRow = true;
	s.Settings.ShowFilterRowMenu = true;
	s.Settings.ShowFooter = true;
	s.Settings.ShowGroupPanel = true;

	s.Columns.Add("CustomNumber", "Nummer");
	s.Columns.Add("Description", "Bezeichnung");
	s.Columns.Add("SiteDescription", "Baustelle");
	s.Columns.Add(column =>
	{
		column.Caption = "Einreichung";
		column.FieldName = "OfferingDate";
		column.PropertiesEdit.DisplayFormatString = "dd.MM.yyyy";
	});
	s.Columns.Add(column =>
	{
		column.Caption = "Angebotssumme";
		column.FieldName = "OfferingValue";
		column.PropertiesEdit.DisplayFormatString = "c2";
	});
	s.Columns.Add(column =>
	{
		column.Caption = "Verhandlungssumme";
		column.FieldName = "NegotiationValue";
		column.PropertiesEdit.DisplayFormatString = "c2";
	});
	s.Columns.Add("DeviationDescription", "Vertragsabweichungen");
	s.Columns.Add("StateDescription", "Status");
	s.Columns.Add("CategoryValuesDescription", "Kategorien");
	s.Columns.Add(column =>
	{
		column.Caption = "Kommentar";
		column.CellStyle.Wrap = DefaultBoolean.True;
		column.SetDataItemTemplateContent(c =>
		{
			var id = Convert.ToInt32(DataBinder.Eval(c.DataItem, "Id"));

			var comment = DataBinder.Eval(c.DataItem, "Comment");
			var text = comment == null
				? String.Empty
				: comment.ToString();

			if (text.ToString().Length > 40)
			{
				ViewContext.Writer.Write(text.Substring(0, 40) + " ...");
				ViewContext.Writer.Write("<a href=\"#\" onclick='showComment(\"appendix\"," + id + ",this)'><br />Anzeigen</a>");
			}
			else
				ViewContext.Writer.Write(text);
		});
	});

	s.TotalSummary.Add(new ASPxSummaryItem
	{
		SummaryType = DevExpress.Data.SummaryItemType.Sum,
		FieldName = "OfferingValue"
	});
	s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "OfferingValue");

	s.TotalSummary.Add(DevExpress.Data.SummaryItemType.Sum, "NegotiationValue");
	s.GroupSummary.Add(DevExpress.Data.SummaryItemType.Sum, "NegotiationValue");

	s.ClientLayout = (sender, e) =>
	{
		if (e.LayoutMode == ClientLayoutMode.Loading)
		{
			if (Session["AppendixGridState"] != null)
				e.LayoutData = (string)Session["AppendixGridState"];
		}
		else
			Session["AppendixGridState"] = e.LayoutData;
	};

	s.Styles.AlternatingRow.BackColor = System.Drawing.Color.FromArgb(247, 247, 247);
}).Bind(Model).GetHtml()*@