Jquery TreeView unexpand nodes
<p>I have a TreeView rendered inside a dialog box. With the dialog box I have a Clear Selections button, My Question is how do I restore the treeview to the default un-expanded state. </p>

<p>Currently If I expand the nodes within the treeview and hit the clear button and open the dialog box again, the tree view is still expanded.</p>

<p>On document.ready for my Dailog box Javascript file, I have the following to initialize the treeview. Should I put this inside a function and upon clear button in dialog box, call this function again to reset?</p>

<p>JS File</p>

<pre class="lang-js prettyprint-override"><code>//This load the tree view on document ready

$("#parts ul").treeview({
  persist: "location",
  collapsed: true,
  prerendered: false
});

Clear: function () {
  $('#partTreeView :checked').removeAttr('checked');
  $("#PartDisplay").text('');
  $("#inputReps").text('');
  $("#parts").attr("style", "display:inline;");
  $("#inputParts").attr("style", "display:none;");
  PartDialog.dialog("destroy");
  //Toggle/Un-expand tree view here if already expanded here
}
</code></pre>

<p>View HTML</p>

<pre class="lang-html prettyprint-override"><code>&lt;!-- This div opens the dialog box --&gt;
&lt;div class="bodyContent"&gt; 
  &lt;span class="leftContent"&gt;
    @Html.Label("Select Parts")
  &lt;/span&gt;
  &lt;span class="rightContent"&gt;
    &lt;span id="PartChildDialogLink" class="treeViewLink"&gt;Click here to Select Parts&lt;/span&gt;
    &lt;br /&gt;
    &lt;span id="PartDisplay"&gt;&lt;/span&gt;
    @Html.HiddenFor(model =&gt; model.PartDescription)
    &lt;input id="ServiceEntryID" type="hidden" value="0" /&gt;
  &lt;/span&gt;
&lt;/div&gt;

&lt;!-- This div contains the dialog box and the tree viwe rendered inside of it --&gt;
&lt;div id="partTreeView" title="Dialog Title" style="font-size: 10px; font-weight: normal; overflow: scroll; width: 800px; height: 450px; display: none;"&gt;
  &lt;div id="parts"&gt;
    &lt;!-- This line renders the treeview just fine --&gt;
    @Html.RenderTree(CacheHelper.Parts(), ec =&gt; ec.Name, ec =&gt; ec.Children.ToList(), ec =&gt; (ec.ID).ToString(), null, "part")
  &lt;/div&gt;
  &lt;div id="inputParts" style="display: none;"&gt;&lt;/div&gt;
  &lt;div id="inputPartTemp" style="display: none;"&gt;&lt;/div&gt;
&lt;/div&gt;
</code></pre>
