dynatree的延迟加载 [英] Lazy Loading in dynatree
问题描述
在此组件中 http://wwwendt.de/tech/dynatree/index.html
在5.4下按需加载子节点(延迟加载")
under 5.4 Loading child nodes on demand ('lazy loading')
看来,以惰性方式加载树节点的唯一方法是从Web服务中获取它们.如果我想从数据结构中获取节点怎么办?
it seems that the only way to load the tree nodes in a lazy manner is to grab them from web service. What if I want to grab the nodes from a data structure?
例如:
onLazyRead: function(dtnode){
dtnode.appendAjax({
//url: "sample-data2.json"
//grab the nodes here from array
});
}
有什么建议吗? 另一个问题:当执行onLazyRead时,是否会再次重新渲染整个树?
Any advice? Another question: when onLazyRead is executed, does the whole tree get re-rendered again?
推荐答案
您可以使用
dtnode.addChild(dict);
代替
.appendAjax(...)
无论哪种情况,都只应渲染已更改的节点.
In either case, only the changed nodes should get rendered.
dict
的格式必须类似于JSON响应.您可以使用toDict()
方法从给定的树或节点生成dict
.
dict
must be formatted like the JSON response. You can als generate dict
from a given tree or node using the toDict()
method.
这篇关于dynatree的延迟加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!