Created
August 6, 2014 18:07
-
-
Save kgiszewski/7389e60ca9d6aad72785 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inherits Umbraco.Web.Mvc.UmbracoViewPage<ArchetypeFieldsetModel> | |
@using TableEditor.Models; | |
@using Archetype.Models; | |
@{ | |
if (Model == null) | |
{ | |
return; | |
} | |
var tableModel = Model.GetValue<TableEditorModel>("table"); | |
var rowIndex = 0; | |
} | |
<div class="table-editor-wrapper @(Model.GetValue<bool>("noPadding") ? "no-padding" : "")"> | |
<table class="@tableModel.TableStyle table table-bordered table-striped"> | |
@{ | |
if (Model.HasValue("headline")) | |
{ | |
<caption> | |
<h4>@Model.GetValue("headline")</h4> | |
</caption> | |
} | |
if(tableModel.UseFirstRowAsHeader) { | |
<thead> | |
@foreach (var column in tableModel.Cells.FirstOrDefault()) | |
{ | |
<th>@Html.Raw(column.Value)</th> | |
} | |
</thead> | |
rowIndex++; | |
} | |
<tbody> | |
@foreach (var row in tableModel.Cells) | |
{ | |
if(tableModel.UseFirstRowAsHeader && row == tableModel.Cells.FirstOrDefault()) { | |
continue; | |
} | |
if (tableModel.UseLastRowAsFooter && row == tableModel.Cells.LastOrDefault() && tableModel.Cells.Count() > 1) | |
{ | |
continue; | |
} | |
<tr class="@tableModel.RowStylesSelected.ElementAtOrDefault(rowIndex)"> | |
@{ | |
var columnIndex = 0; | |
foreach (var column in row) | |
{ | |
var columnStyles = tableModel.ColumnStylesSelected.ElementAtOrDefault(columnIndex); | |
<td class="@columnStyles"> | |
@if ( columnStyles != null && columnStyles.Contains("row-header")) | |
{ | |
<span class="title-normal text-uppercase">@Html.Raw(column.Value)</span> | |
} | |
else | |
{ | |
@Html.Raw(Umbraco.ReplaceLineBreaksForHtml(column.Value)) | |
} | |
</td> | |
columnIndex++; | |
} | |
rowIndex++; | |
} | |
</tr> | |
} | |
</tbody> | |
if (tableModel.UseLastRowAsFooter && tableModel.Cells.Count() > 1) | |
{ | |
var columnIndex = 0; | |
<tfoot> | |
@foreach (var column in tableModel.Cells.LastOrDefault()) | |
{ | |
<td class="@tableModel.ColumnStylesSelected.ElementAtOrDefault(columnIndex)">@Html.Raw(column.Value)</td> | |
columnIndex++; | |
} | |
</tfoot> | |
} | |
} | |
</table> | |
@Html.Raw(Model.GetValue("notes")) | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment