在Bootstrap Accordion MVC和C#

时间:2018-02-18 20:32:57

标签: c# asp.net-mvc bootstrap-4

任何人都可以帮助我: 我尝试在Bootstrap手风琴中显示组和组项目,在主组中显示主组和手风琴标题组。

现在我有子菜单作为主要组的菜单,并且通过从主组传递parentID,我只能加载一个选定组的组项。我想要实现的是在Accordion中同时加载所有组及其组项。

你能帮我找到实现这个目标的方法吗?

谢谢......

以下是我当前菜单的示例:

Current Menu with Main Groups

这是我得到的:

Current Result

我想要实现的目标:

Trying to achieve

现在我在_Layout.cshtml中使用此代码作为菜单:

<li class="dropdown">
              <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Groups <span class="caret"></span></a>
              <ul class="dropdown-menu">          
                <li id="GroupSearch">@Html.ActionLink("Main Group 1", "GroupIndex", "Search", new {parentID = 1}, null)</li>
                <li role="separator" class="divider"></li>
                <li id="GroupSearch">@Html.ActionLink("Main Group 2", "GroupIndex", "Search", new {parentID = 2}, null)</li>
                <li role="separator" class="divider"></li>
                <li id="GroupSearch">@Html.ActionLink("Main Group 3", "GroupIndex", "Search", new {parentID = 3}, null)</li>
                <li role="separator" class="divider"></li>
                <li id="GroupSearch">@Html.ActionLink("Main Group 4", "GroupIndex", "Search", new {parentID = 4}, null)</li>
                <li role="separator" class="divider"></li>
                <li id="GroupSearch">@Html.ActionLink("Main Group 5", "GroupIndex", "Search", new {parentID = 5}, null)</li>

              </ul>
            </li> 

我的控制器:

public ActionResult GroupIndex(int? parentID = null)
        {
            ViewBag.Groups = articlesRepository.GetGroups(parentID);

            return View();
        }

和GroupIndex查看:

@using Appp.Domain;

@{
    ViewBag.Title = "Home";
    Layout = "~/Views/Shared/_Layout.cshtml";

    var groups = (List<Appp.Domain.Entities.Groups>)ViewBag.Groups;

}

<div class="row">
    <div class="col-md-4">
        <div class="row">
            <div class="list-group">
                @foreach (var group in groups)
                {
                    <button type="button" class="list-group-item" groupid="@group.ID">@group.Name</button>
                }
                <div class="list-group-item">
                    <form id="searchbygroupform">
                        <input id="groupid" name="groupid" type="hidden" />
                        <div class="input-group input-group-sm">
                            <input type="text" class="form-control" name="searchkeyword" id="searchkeyword" disabled>
                            <span class="input-group-btn">
                                <button class="btn btn-primary" type="button" name="groupsearch" id="groupsearch" disabled>
                                    Serach
                                </button>
                            </span>
                        </div>
                    </form>
                </div>
            </div>
    </div>

0 个答案:

没有答案