title: slow jquery treeview loading
body: <p>I have a jquery treeview which I grabbed from <a href="http://jquery.bassistance.de/treeview/demo/" rel="nofollow">http://jquery.bassistance.de/treeview/demo/</a></p>
  
  <p>when the number of nodes and sub nodes were small I had no problem loading the tree, but as the content grows the loading is taking very long time almost to the point that using the treeview seems a bad idea.</p>
  
  <p>this is part of my view where I construct the treeview</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
      $(function () {
          $("#Ul1").treeview({
  
              collapsed: true,
              prerendered: true
  
          });
  
  
      });
  
  &lt;/script&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;ul id="Ul1" class="treeview-black"&gt;
  &lt;%
      foreach (var t in (IEnumerable&lt;itemSpecifications&gt;)ViewData["items"])
  {%&gt;
  
      &lt;li class="expandable"&gt;&lt;span&gt;&lt;%=Html.RouteLink(t.itemName, null, new { controller = "RQA", action = "itemaction", policyname = t.itemName})%&gt;&lt;/span&gt;
       &lt;%if (t.itemCount &gt; 0)
         {%&gt;
  
                  &lt;%for(int i=0;i&lt;t.itemCount ;i++){%&gt;
                                                       &lt;ul&gt;
                                                                  &lt;li class="expandable"&gt;&lt;span&gt;&lt;%=Html.RouteLink(t.subitems[i].Name, null, new { controller = "controller1", action = "itemUpdate", rule = t.subitems[i] })%&gt;&lt;/span&gt;&lt;/li&gt;
  
  
                                                    &lt;/ul&gt; 
                                                  &lt;%}%&gt;
  
  
        &lt;%}%&gt;
  
  &lt;% }%&gt;
  &lt;/li&gt;
  
  &lt;/ul&gt;
  </code></pre>
  
  <p>and the controller contains the code below:</p>
  
  <pre><code>public ActionResult Index()
      {     
  
              items1 = (from itemsInfo itemInfo in _itemInfoCollection
                           where itemInfo.Name == "val1"  
                           select new itemSpecifications
                           {
                               itemName = itemInfo.Name,
                            itemCount = GetItemscount(),                                 subitems = GetSubItems()                             });
  
                ViewData["items"] = items1 ;
                 return View();
      }
  </code></pre>
  
  <p>sometimes the loading of the entire page takes so long that the page basicaly crashes (unable to load) and sometimes when the page loads successfully and I click on any of the plus signs next to the nodes it takes such a long time to open the subitems. it is worth to mention that the average subnodes are 400 items, any advise will be highly appreciated, I am using MVC3 and it is in IE</p>
  
  <p>Thanks</p>