title: How to modify how the custom field looks on sharepoint list (allitems view)?
body: <p>I'm trying to write a custom field that is representing the time spend on the task. The field derives from NumberField (number is representing minutes) but I want to display it on the list as HH:MM for that purpose I've tried to override the fallowing function:</p>
  
  <pre><code>        protected override void RenderFieldForDisplay(System.Web.UI.HtmlTextWriter output)
      {
          Label timeSpan = new Label();
          timeSpan.Text = ((int)this.Value / 60).ToString() + ":" + ((int)this.Value % 60).ToString();
          timeSpan.RenderControl(output);
          //base.RenderFieldForDisplay(timeSpan.RenderControl());
      }
  </code></pre>
  
  <p>I'm not an ASP.NET developer so I'm trying to avoid defining DisplayTemplate. </p>
  
  <p>Can you show me the way how to render it programmatically or just push me in the right direction?</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Solved with help from Kusek answer. In fldtypes_HourField.xml:</p>
  
  <pre><code>&lt;RenderPattern Name="DisplayPattern"&gt;
    &lt;HTML&gt;&lt;![CDATA[&lt;div align='right'&gt;]]&gt;&lt;/HTML&gt;
    &lt;Switch&gt;
      &lt;Expr&gt;
        &lt;Column /&gt;
      &lt;/Expr&gt;
      &lt;Case Value="" /&gt;
      &lt;Default&gt;
        &lt;HTML&gt;&lt;![CDATA[&lt;script src="/_layouts/hourField.js"&gt;&lt;/script&gt;]]&gt;&lt;/HTML&gt;
        &lt;HTML&gt;&lt;![CDATA[&lt;div&gt;&lt;SCRIPT&gt;formatHourField("]]&gt;&lt;/HTML&gt;
        &lt;Column /&gt;
        &lt;HTML&gt;&lt;![CDATA[");&lt;/SCRIPT&gt;&lt;/div&gt;]]&gt;&lt;/HTML&gt;
      &lt;/Default&gt;
    &lt;/Switch&gt;
  &lt;/RenderPattern&gt;
  </code></pre>
  
  <p>And the hourField.js</p>
  
  <pre><code>function formatHourField(t) {
      var m = t % 60;
      var h = (t - m)/ 60;
      document.write(h + ":" + m);
  }
  </code></pre>
  
  <p>Having in mind what I've tried before - this solution looks beautifully simple :)</p>