事件上的 Dynatree 显示同级或动态更改数据
DynaTree 使用的数据可以动态更改吗?
我有一组与动态树相关的完整数据,但我只想显示树的某个分支,因此我迭代数据并获取我想要的节点并创建树,这工作正常。
我想做的是有一个按钮,使当前节点的兄弟节点可见。本质上,用户负责他们默认看到的一个节点,但如果他们也需要,他们也可以看到当前节点的兄弟节点。
我可以重新迭代数据并选择父节点并将数据设置为父节点,但树不会更新。
我尝试过:
tree.reload();
tree.renderInvisibleNodes()
tree.redraw();
并将元素设置为空并使用新设置重新创建树
$('#i2o-tree').empty();
$('#i2o-tree').dynatree(new_settings);
Can data that DynaTree uses be changed dynamically?
I have a complete set of data that relates to dynatree, but I want to display only a certain branch of the tree so I iterate over the data and take the node I want and create the tree, this works fine.
What I would like to do is have a button that makes the siblings of the current node visible. essentially a user is in charge of one node which they see by defaault, but they can see siblings of the current node if they need too.
I can re-iterate over the data and select the parent node and set the data to the parent but the tree doesnt update.
I've tried:
tree.reload();
tree.renderInvisibleNodes()
tree.redraw();
and setting the element to empty and recreating the tree with the new settings
$('#i2o-tree').empty();
$('#i2o-tree').dynatree(new_settings);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
刚刚开始工作,希望这对将来的人有帮助。
由于 dynatree 是一个 jQuery 插件,如果您确实需要重新加载数据并重新渲染树,请调用 jQuery 的“destroy”方法:
Just got this to work, Hope this helps someone in future.
Since dynatree is a jQuery plugin, if you really need to reload the data and re-render the tree you and call jQuery's 'destroy' method: