问题描述
http://wwwendt.de/tech/dynatree/index.html
我想澄清以下几点:调用addChild时-是重新渲染整个树还是仅修改节点(添加的节点和具有新子节点的节点)?
I would like to clarify the following:when addChild is invoked - does the whole tree gets re-rendered or just the nodes modified (added nodes and the nodes that have new children)?
我得到2条相互矛盾的信息:在dynatree中延迟加载它说只有受影响的节点才会被重新渲染
I am getting 2 conflicting pieces of info:Lazy Loading in dynatree it says that only affected nodes will get re-rendered
动态加载100多个节点时,Dynatree变慢一个>这里说它确实在每次使用addChild时都会重新渲染
Dynatree slow when dynamically loaded with 100+ nodeshere it says that it does get re-rendered every time addChild is used
也许我想念什么吗?
是哪个?
推荐答案
Dynatree将节点存储在内部结构中.渲染"是在以下环境中创建或更新HTML元素的过程DOM到反映树的状态.例如,分支中的最后一个节点具有特殊的类名,因此附加一个节点需要从先前的最后一个节点"中删除此类,并且将其添加到新的.
Dynatree stores the nodes in an internal structure.'Rendering' is the process of creating or updating HTML elements inthe DOM toreflect the tree's status.For example the last node in a branch has a special class name, soappending anode requires removing this class from the previous 'last node' andadding it tothe new one.
每次调用.addChild(data)时,都会触发渲染.如果您通过一次调用传递了100个节点,则渲染仅完成一次,所以这总是比一个叫100次更好单节点.
Every time you call .addChild(data), the rendering is triggered.If you pass 100 nodes with one call, the rendering is done only once,sothis is always more performant than calling it 100 times with onesingle node.
当前(0.5.4版)addChild使用以下模式:
Currently (release 0.5.4) addChild uses this pattern:
var prevFlag = tree.enableUpdate(false);
[modify the tree]
tree.enableUpdate(prevFlag);
enableUpdate(true)调用tree.redraw(),因此将更新整个树.这将在1.0版中进行了更改,但即使这样,合并起来也会更快addChild电话.
enableUpdate(true) calls tree.redraw(), so the whole tree is updated.This willchange with release 1.0, but even then it will be faster to combineaddChildcalls.
另一方面是:何时是在DOM中创建的节点.从1.0开始,将HTML元素的创建推迟到节点变成首次可见(展开).因此有可能将大量节点加载到高效内部Dynatree数据结构而不会膨胀DOM.
Another aspect is: when are nodes created in the DOM.Starting with 1.0 creation of HTML elements is deferred until the nodebecomesvisible (expanded) for the first time.So it is possible to load a very large number of nodes into the efficientinternal Dynatree data strucure without bloating the DOM.
如果对用户更友好,则可以预加载整个树,也可以延迟加载单身的按需分支取决于服务器,网络和客户端.所以是总是对不同场景进行基准测试的问题.
If it is more user friendly to pre-load the whole tree, or lazy-loadsinglebranches on demand depends on server, network and client. So it'salwaysa matter of benchmarking the different scenarios.
这篇关于Dynatree addChild-组件作者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!