Note that there are some explanatory texts on larger screens.

plurals
  1. POTreeView simple menu example with <ul> and <li> tags in MVC
    primarykey
    data
    text
    <h2>TreeView Example</h2> <p><strong>Hare is my Model:</strong></p> <pre><code>public class EditUser { public int Id { get; set; } public string UserId { get; set; } public string UserName { get; set; } public string Description { get; set; } public int ServiceCount { get; set; } public int TransCount { get; set; } public string Email { get; set; } public List&lt;ServiceEnrolled&gt; Services { get; set; } } public class ServiceEnrolled { public string UserId { get; set; } public int ServiceId { get; set; } public string ServiceName { get; set; } public List&lt;ServiceTransaction&gt; Transactions { get; set; } } public class ServiceTransaction { public int Id { get; set; } public string UserId { get; set; } public int ServiceId { get; set; } public string TransactionName { get; set; } public bool IsChecked { get; set; } } </code></pre> <p><strong>hare is my View:</strong></p> <pre><code>@model ServiceCatalogUpgrade.Models.EditUser for (int i = 0; i &lt; Model.Services.Count(); i++) { @Html.HiddenFor( x =&gt; x.Services[i].ServiceId) &lt;div class="wtree"&gt; &lt;ul class="ulclass"&gt; &lt;img alt="" width="18" height="18" class="expand" src="~/Images/minus.ico" /&gt; &lt;img alt="" width="18" height="18" class="collapse" src="~/Images/plus.ico" /&gt; &lt;input class="checkbox" type="checkbox" /&gt; &lt;span style="font-weight: bold;"&gt;@Html.DisplayFor(x =&gt;x.Services[i].ServiceName)&lt;/span&gt; @for (int j = 0; j &lt; Model.Services[i].Transactions.Count(); j++) { &lt;li style="list-style:none;"&gt; @Html.EditorFor(x =&gt; x.Services[i].Transactions[j].IsChecked) @Html.DisplayFor(x =&gt;x.Services[i].Transactions[j].TransactionName) &lt;/li&gt; @Html.HiddenFor( x =&gt; x.Services[i].Transactions[j].ServiceId) @Html.HiddenFor( x =&gt; x.Services[i].Transactions[j].UserId) @Html.HiddenFor( x =&gt; x.Services[i].Transactions[j].TransactionName) } &lt;/ul&gt; &lt;/div&gt; } </code></pre> <p>Hare is My Jquery:</p> <pre><code>&lt;script type="text/javascript"&gt; $(".expand").click(function () { $(this).toggle(); $(this).parent().find('.collapse').toggle(); $(this).parent().find('li').toggle(); }); $(".collapse").click(function () { $(this).toggle(); $(this).parent().find('.expand').toggle(); $(this).parent().find('li').toggle(); }); //select all or deselect all checkboxs $(".checkbox").click(function () { if ($(this).attr("checked") == undefined) { $(this).parent().parent().find("input[type='checkbox']").each(function () { $(this).removeAttr("checked"); }); } else { $(this).parent().parent().find("input[type='checkbox']").each(function () { $(this).attr("checked", "checked"); }); } }); </code></pre> <p></p> <p>When I searched TreeView in internet, I thought all TreeView example is more difficult whan it seems. I decided to write code.<br> I write this code on my own. Does this Treeview build method is good ? May I optimize this Jquery code ? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload