相关疑难解决方法(0)

在Asp.Net MVC中使用JsTree延迟加载TreeView

我在我的项目中使用JsTree.我想这样做:

我想在单击根节点(+)或子节点时显示子节点后第一次加载树时,只显示根节点.我的意思是,当我点击每个节点时,我想从数据库中获取并添加到子节点.

我怎么能在Asp.Net MVC中做到这一点?我查看了几乎每个JsTree Ajax示例.但我不能这样做.我该怎么回事呢?我该怎么做我的行动请帮忙!

JsTree:https://www.jstree.com/

样品:

c# asp.net-mvc dynamic jstree

11
推荐指数
2
解决办法
1万
查看次数

ASP.NET MVC:使用递归助手生成多级菜单

我使用此代码生成菜单,此菜单使用此技术从数据库(类别表)填充项目

局部视图:

@using SarbarzDarb.Helper
@model IEnumerable<SarbarzDarb.Models.Entities.Category>

@ShowTree(Model)

@helper ShowTree(IEnumerable<SarbarzDarb.Models.Entities.Category> categories)
{
        foreach (var item in categories)
        {
            <li class="@(item.ParentId == null && item.Children.Any() ? "dropdown-submenu" : "")">

                @Html.ActionLink(item.Name, actionName: "Category", controllerName: "Product", routeValues: new { Id = item.Id, productName = item.Name.ToSeoUrl() }, htmlAttributes: null)

                @if (item.Children.Any())
                {
                    ShowTree(item.Children);
                }

            </li>

        }
}
Run Code Online (Sandbox Code Playgroud)

我也是这样通过模型从控制器传递到局部视图以上:

public IList<Category> GetAll()
{

        return _category.Where(category => category.ParentId == null)
                        .Include(category => category.Children).ToList();
}
public ActionResult Categories()
{
            var query = GetAll();
            return PartialView("_Categories",query);
} …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc recursion entity-relationship razor ef-code-first

2
推荐指数
1
解决办法
8930
查看次数