Advertisement
Guest User

FieldType.DropDownList.cshtml

a guest
Jun 24th, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.12 KB | None | 0 0
  1. @using System.Text;
  2. @model Umbraco.Forms.Mvc.Models.FieldViewModel
  3.  
  4. @if (Model.Value!= null){
  5.            
  6.             List<string> cols = new List<string>();
  7.             List<string> rows = new List<string>();
  8.            
  9.                 foreach (Umbraco.Forms.Mvc.Models.PrevalueViewModel item in Model.PreValues)
  10.                 {
  11.                     string itemStr = item.Value.ToString();
  12.                     if (itemStr.Contains("[a]"))
  13.                     {
  14.                         cols.Add(itemStr.Replace("[a]", ""));
  15.                     }
  16.                     else if (itemStr.Contains("[q]") || itemStr.Contains("[h]"))
  17.                     {
  18.                         rows.Add(itemStr.Replace("[q]", ""));
  19.                     }
  20.                 }
  21.  
  22.            
  23.  
  24.             StringBuilder sb = new StringBuilder();
  25.             sb.Append("<table class=\"matrix_control\">");
  26.             sb.Append("<thead>");
  27.             sb.Append("<tr>");
  28.             sb.Append("<td><h6></h6></td>");
  29.             foreach (string colPreval in cols)
  30.             {
  31.                 sb.Append(string.Format("<td><h6>{0}</h6></td>", colPreval));
  32.             }
  33.             sb.Append("</tr>");
  34.             sb.Append("</thead>");
  35.             sb.Append("<tbody>");
  36.             foreach (string rowPreval in rows)
  37.             {
  38.                 if (rowPreval.Contains("[h]"))
  39.                 {
  40.                     sb.Append(string.Format("<tr><td colspan=\"{0}\"><span>{1}</span></td></tr>", cols.Count + 1, rowPreval.Replace("[h]", "")));
  41.                 }
  42.                 else
  43.                 {
  44.                     sb.Append("<tr>");
  45.                     sb.Append(string.Format("<td><span>{0}</span></td>", rowPreval));
  46.                     Guid group = Guid.NewGuid();
  47.                     for (int i = 0; i < cols.Count; i++)
  48.                     {
  49.                         sb.Append(string.Format("<td><input type=\"radio\" name=\"{0}\" /></td>", group));
  50.                     }
  51.                     sb.Append("</tr>");
  52.                 }
  53.  
  54.             }
  55.             sb.Append("</tbody>");
  56.             sb.Append("</table>");
  57.             <div>@Html.Raw(sb.ToString())</div>
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement