如何使用TreeEx by DevExpress导航网站

时间:2014-09-23 09:50:38

标签: c# asp.net-mvc treeview devexpress devexpress-mvc

我目前正在使用DevExpress的TreeView,它用于在我的ASP mvc网站中导航。

但是,阅读docs,我似乎无法找到对实际导航的任何引用,尤其是当我绑定xml文件中的数据时。

我的ContentLeftPartialView

<div class="leftPanel">
        @* DXCOMMENT: Configure the left panel's treeview *@
    @Html.DevExpress().TreeView(settings => {
        settings.Name = "LeftTreeView";
    }).BindToXML(HttpContext.Current.Server.MapPath("~/App_Data/SideMenu.xml"), "/menu/*").GetHtml()
</div>

xml的基础知识

<?xml version="1.0" encoding="utf-8" ?>
<menu>
  <group Text="Graphics">
    <item Text="General Overview" />
  </group>
  <group Text="Reports">
    <item Text="Report Manager" />
    <item Text="Product Delivery Report" />
    <item Text="Inventory Report" />
    <item Text="Stock Report" />
  </group>
 <group Text="Stocks">
    <item Text="stock 1" />
    <item Text="stock 2" />
  </group>
 <group Text="Systems">
    <item Text="system 1" />
    <item Text="system 2" />
  </group>
 <group Text="Lock Interface">
  </group>
   <group Text="Settings">
  </group>
</menu>

我完全不知道我应该放置ActionLinks / etc的位置,以便我可以在整个网站中导航(此面板将在所有页面中保持不变)。

有没有人有过使用DevExpress的HTML 5 / MVC的经验,指出我的方向正确?

我知道另一个项目使用了这个:

 public ActionResult Products()
        {
            ViewBag.Message = "Your Products page.";

            return View();
        }

但它只使用了以下链接:

 <li>@Html.ActionLink("Products", "Index", "Products")</li>

我不认为DevExpress的树视图会在局部视图中发生。

1 个答案:

答案 0 :(得分:1)

我发现了如何使用xml文件中的NavigateUrl进行导航,虽然这不是我想放置它的位置(我希望动态添加它)。

但是,使用:

 <group Text="Graphics">
    <item Text="General Overview" NavigateUrl="/mygraphicsPage"/>
 </group>

允许我按treeview上的“常规概览”,这将导航至“mygraphicsPage.cshtml”。

所以重要的页面是添加

NavigateUrl="myurl" to the items.