ダイアログボックス内にTreeViewをレンダリングしています。ダイアログボックスに[選択をクリア]ボタンがあります。私の質問は、ツリービューをデフォルトの非展開状態に復元する方法です。
現在、ツリービュー内のノードを展開し、クリアボタンを押してダイアログボックスを再度開くと、ツリービューは引き続き展開されます。
私のDailogボックスJavascriptファイルのdocument.readyには、ツリービューを初期化するために次のものがあります。これを関数内に配置し、ダイアログボックスのボタンをクリアしたら、この関数を再度呼び出してリセットする必要がありますか?
JSファイル
//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
}
HTMLを表示
<!-- This div opens the dialog box -->
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Select Parts")
</span>
<span class="rightContent">
<span id="PartChildDialogLink" class="treeViewLink">Click here to Select Parts</span>
<br />
<span id="PartDisplay"></span>
@Html.HiddenFor(model => model.PartDescription)
<input id="ServiceEntryID" type="hidden" value="0" />
</span>
</div>
<!-- This div contains the dialog box and the tree viwe rendered inside of it -->
<div id="partTreeView" title="Dialog Title" style="font-size: 10px; font-weight: normal; overflow: scroll; width: 800px; height: 450px; display: none;">
<div id="parts">
<!-- This line renders the treeview just fine -->
@Html.RenderTree(CacheHelper.Parts(), ec => ec.Name, ec => ec.Children.ToList(), ec => (ec.ID).ToString(), null, "part")
</div>
<div id="inputParts" style="display: none;"></div>
<div id="inputPartTemp" style="display: none;"></div>
</div>