【问题标题】:Build a hierarchical data structure to bind to treeview构建分层数据结构以绑定到树视图
【发布时间】:2013-08-06 22:08:35
【问题描述】:

在将 Windows 文件系统构建到树视图中时,我需要一些帮助。我不确定我是否做对了。下面是我建立的类。我需要能够从根文件夹填充它并将数据转换为 Json 以便能够将其绑定到视图中的树视图。

    public class Folder
    {
      public int id { get; set; }
      public string Name { get; set; }
      public List<Folder> ChildFolders { get; set; }
    }

感谢您的帮助。

【问题讨论】:

  • 您使用的是什么 TreeView?你自己开发了吗?
  • 我正在使用 kendoUI TreeView demos.kendoui.com/web/treeview/index.html
  • 那么,您的模型有什么问题?为什么需要将数据转换为 Json?是否要动态添加/删除节点?

标签: asp.net-mvc data-structures treeview kendo-ui


【解决方案1】:
  1. 首先添加一个parent字段,例如public Folder Parent {get;set;}

如果我们谈论的是 Web UI:

  1. 使用&lt;ul&gt; &lt;li&gt; 结构,并使用css 像:.tree > ul > li { //一些填充} 等等。
  2. 编写一个递归 Html.Helper 来构造嵌套列表结构

【讨论】:

    猜你喜欢
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 2012-03-11
    • 2015-07-20
    • 1970-01-01
    • 2017-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多