问题描述
我评估在项目中使用,将在树视图控件显示一个分层模型(想想Windows文件浏览器)。
I'm evaluating the Backbone javascript framework for use in a project that will display a hierarchical model in a tree view widget (think the Windows file browser).
我的爱的骨干怎么想了解世界。但是,有很多的编码参与之前,我得到一个概念证明有骨干实际接收来自服务器的分层模型和更新树部件。我见过有不同的解决方案,re$p$psenting与骨干深层数据结构,但我不知道......有没有人真正做到了这一点?
I love how Backbone thinks about the world. However, there's a lot of coding involved before I get to a proof of concept that has Backbone actually receiving a hierarchical model from a server and updating a tree widget. I've seen there's various solutions for representing deep data structures with Backbone, but I'm wondering... has anyone actually done this?
只知道它可能会是一个帮助。其实命名为使数据分层骨干会更好树视图UI组件和指针。样品code的一点是令人惊讶的太棒了。
Just knowing that it's possible would be a help. Actually naming the tree view UI component and pointers for making data hierarchical in Backbone would be even better. A bit of sample code would be amazingly fantastic.
据数据的大小,树将运行100的节点(文件夹)与叶项低1000的(文件),并且这将是很好,每次当用户点击逐步加载数据(比如,一个文件夹在),虽然这可能不是一个搅局者。
As far as data size, tree will run 100's of nodes (folders) with low 1000's of leaf items (documents), and it would be nice to progressively load the data (say, one folder at a time as the user clicks in), though that's probably not a showstopper.
谢谢!
推荐答案
如果你不想旅行下来的分层数据集路一个选择,就是用一组嵌套(的)。这使您可以在整个集合存储在一个数组(或列表或任何你想将它命名),并使用左和右值来确定列表的结构和层次。
one option if you don't want to travel down the hierarchical data-set path, is to use a Nested Set (http://en.wikipedia.org/wiki/Nested_set_model). this allows you to store the entire collection in a single array (or list or whatever you want to call it) and use a "left" and "right" value to determine the structure and hierarchy of the list.
如果我记得没错,这种技术最初是建立以优化数据存储和查询,在关系数据库中。不过,我已经用它的一些在C#/的WinForms应用时间,以避免数据的递归层次结构,而且运作良好。
if i remember right, this technique was originally build to optimize data storage and queries in a relational database. however, i've used it a number of times in C#/Winforms applications, to avoid having a recursive hierarchy of data, and it worked well.
这在JavaScript实现应该是pretty容易,但我不知道它会如何与大名单执行。
an implementation of this in javascript should be pretty easy, but i don't know how well it would perform with a large list.
这篇关于骨干与树视图控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!