replacement of asp:Treeview for ASP.NET MVC applic

2019-07-14 05:46发布

I thus far worked with asp:Treeview for all my dynamic menus for my web applications..

Any suitable replacement of it in an asp.net mvc web application...

  • Any HTML helper that can perform like Treeview for me?

3条回答
爷的心禁止访问
2楼-- · 2019-07-14 06:00

I would use jQuery based plugin. Like this one.

查看更多
干净又极端
3楼-- · 2019-07-14 06:15

As Arnis said, using Jquery Pluggin, it is so easy! I do it by encapsulating the code and html in a Partial View as a UserControl. You can do it by a recursive logic:

@helper ShowTree(TreeItem item, IEnumerable<TreeItem> tree)
    {

        var childs = folders.Where(g => g.ParentId == item.Id);
        if (childs.Count() == 0)
        {
    <text>
    <li class="last"><span class="folder">@item.Title</span></li>
    </text>
        }
        else
        {
    <text>
    <li class="expandable">
        <div class="hitarea expandable-hitarea">
        </div>
        <span class="folder">@item.Title</span>
        <ul style="display: none;">
            @{foreach (var child in childs)
              {
                @ShowTree(child, folders)
              }
            }
        </ul>
    </li>
    </text>
        }
}
查看更多
等我变得足够好
4楼-- · 2019-07-14 06:21

In my Mvc Controls Toolkit I have a server control based on the jQuery TreView. However, I allow node editing, insertion ov new nodes, and moving sub-tree into another location by dragging it with the mouse. All changes are reflected Automatically on data structures on the server side when the view is posted. Moreover all nodes are templated and the same tree can have different type of nodes. Give a look here: http://mvccontrolstoolkit.codeplex.com/wikipage?title=TreeView

查看更多
登录 后发表回答