多级树视图
我正在努力将三个级别绑定到我的 telerik treeView
+Directories
*Archives
-Documents
*Directories
这是我的代码:
<% Html.Telerik().TreeView()
.Name("TeleTreeView")
.DragAndDrop(true)
.ExpandAll(true)
.BindTo(Model, mappings =>
{
mappings.For<SARS.Directory>(binding => binding
.ItemDataBound((item, directory) =>
{
item.Text = (string)directory.DirectoryName;
item.Value = (string)directory.NodeID;
item.ImagUrl="~/Images/Folder-Add-icon.png";
})
//Sub Directories
.Children(directory => directory.Directory1));
mappings.For<SARS.Directory>(binding => binding
.ItemDataBound((item, dir) =>
{
item.Text = dir.DirectoryName;
item.Value = (string)dir.NodeID;
item.ImagUrl="~/Images/Folder-Add-icon.png";
})
//Sub archives
.Children(directory => directory.Archives));
mappings.For<SARS.Archive>(binding => binding
.ItemDataBound((item, arch) =>
{
item.Text = arch.ArchiveName;
}));
})
.Render();%>
编辑:问题是我没有获得档案级别。 我应该怎么办?
I'm working on binding three levels to my telerik treeView
+Directories
*Archives
-Documents
*Directories
This is my code:
<% Html.Telerik().TreeView()
.Name("TeleTreeView")
.DragAndDrop(true)
.ExpandAll(true)
.BindTo(Model, mappings =>
{
mappings.For<SARS.Directory>(binding => binding
.ItemDataBound((item, directory) =>
{
item.Text = (string)directory.DirectoryName;
item.Value = (string)directory.NodeID;
item.ImagUrl="~/Images/Folder-Add-icon.png";
})
//Sub Directories
.Children(directory => directory.Directory1));
mappings.For<SARS.Directory>(binding => binding
.ItemDataBound((item, dir) =>
{
item.Text = dir.DirectoryName;
item.Value = (string)dir.NodeID;
item.ImagUrl="~/Images/Folder-Add-icon.png";
})
//Sub archives
.Children(directory => directory.Archives));
mappings.For<SARS.Archive>(binding => binding
.ItemDataBound((item, arch) =>
{
item.Text = arch.ArchiveName;
}));
})
.Render();%>
Edit:The problem is that I'm not getting the Archives level.
What should I do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Directory1应该包含一个像Archives这样的类的Iennumerable列表,那么很容易获得子节点。我尝试过最多 4 级层次结构。
Directory1 should contains a Iennumerable list of a class like Archives , then its easy to get the child nodes . I have tried upto 4 levels of hierarchy.
目前不支持此功能。您不能指定不同类型的子项。第二次调用
Children()
将覆盖前一个。This is not currently supported. You cannot specify children of different type. The second call to
Children()
will overwrite the previous one.我最近遇到了同样的问题,一些节点子节点将具有不同和/或混合类型:
我解决这个问题的方法是简单地引入各种类型的接口,然后将树视图绑定到该接口:
I recently had the same problem whereby some nodes children would be of a different and/or mixed type:
The way I resolved this was to simply introduce an interface on the various types and then bind the treeview to the interface: