title: TreeView in ASP. NET Core MVC using RAZOR engine without JS libraries
body: <p>I have an issue that usual System.Web.UI.WebControls with  @(Html.TreeView(Model) is not implemented in ASP.NET Core. Is it possible to a implement hierarchy tree view with recursion using only Razor, html?</p>
  
  <p>There is my tree node model:</p>
  
  <pre><code>public class EmployeeTree
  {
      public EmployeeTree()
      {
          Reporters = new List&lt;EmployeeTree&gt;();
      }
      public int Id { get; set; }
      public int? ManagerId { get; set; } 
      [Required]
      [MaxLength(30)]
      public string FirstName { get; set; }
      [Required]
      [MaxLength(30)]
      public string SecondName { get; set; }
      [Required]
      [MaxLength(30)]
      public string Position { get; set; }
      public string Phone { get; set; }
  
      public virtual EmployeeTree Manager { get; set; }
      public virtual List&lt;EmployeeTree&gt; Reporters { get; set; }
  }
  </code></pre>
  
  <p>I tried such recursion Razor with @functions helper, but it did not load child elements. Any suggestions, whats wrong?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>@using System.Text
  
  @functions{
      void GetEmployeeTree(EmployeeTree data)
      {
          StringBuilder output = new StringBuilder();
          output.Append("Employee");
          output.Append("&lt;li&gt;");
          output.Append(data.FirstName);
          if (data.Reporters.Count &gt; 0)
          {
              foreach (var dataNode in data.Reporters)
              {
                  output.Append("&lt;ul&gt;");
                  output.Append(dataNode.FirstName);
                  GetEmployeeTree(dataNode);
                  output.Append("&lt;/ul&gt;");
              }
          }
          output.Append("&lt;/li&gt;");
      }
  }</code></pre>
  </div>
  </div>
  </p>