Dynatree addChild-组件作者的问题 [英] Dynatree addChild - question for the component's author

查看:72
本文介绍了Dynatree addChild-组件作者的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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+ nodes here 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 in the DOM to reflect the tree's status. For example the last node in a branch has a special class name, so appending a node requires removing this class from the previous 'last node' and adding it to the 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, so this is always more performant than calling it 100 times with one single 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 will change with release 1.0, but even then it will be faster to combine addChild calls.

另一方面是:何时是在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 node becomes visible (expanded) for the first time. So it is possible to load a very large number of nodes into the efficient internal Dynatree data strucure without bloating the DOM.

如果对用户更友好,则可以预加载整个树,也可以延迟加载 单身的 按需分支取决于服务器,网络和客户端.所以是 总是 对不同场景进行基准测试的问题.

If it is more user friendly to pre-load the whole tree, or lazy-load single branches on demand depends on server, network and client. So it's always a matter of benchmarking the different scenarios.

这篇关于Dynatree addChild-组件作者的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆