jstree 的问题可以扩展没有子节点的节点

发布于 2024-12-05 17:41:44 字数 496 浏览 0 评论 0原文

我正在使用 jstree 和 ajax 进行工作,我发现我的所有节点都有展开它的箭头,即使是那些没有子节点的节点。在 jstree http://www.jstree.com/demo 的演示页面上,情况并非如此。我在演示代码中没有看到与我的不同的东西,那么它来自服务器吗?我是否有一个参数来响应“getChildren”方法,在 jstree 上说“这个,没有孩子,不能扩展它”?

有谁知道它是从哪里来的吗?我能做些什么来解决这个问题?

因为当我使用contextmenu插件的复制/粘贴功能时,这似乎是一个问题。当我粘贴到没有子节点且尚未打开(因此子节点尚未加载)的节点(新父节点)时,除了获取子节点的请求(就像我单击打开节点)明显不返回任何内容之外,没有任何反应。并且它不执行 move_node 函数。

编辑:我对上下文菜单中的“添加”有同样的问题

有人可以帮助我吗?

谢谢

I'm working with jstree with ajax and I see that all my nodes have the arrow to expand it, even those which have no children. On the demo page of jstree http://www.jstree.com/demo this is not the case. I don't see on the demo code something different from mine, so does it come from the server ? Have I a parameter to put in response of "getChildren" method to say at jstree "this one, have no children, don't enable to expand it"?

Anyone know from where it come from? And what can I do to fix that ?

Because it seems to be a problem when I used the copy / paste function of the contextmenu plugin. When I paste on a node (the new parent) with no children and not yet open (so children haven't been loaded), nothing happen except the request to get children (like if I click to open the node) that return nothing obviously. And it doesn't execute the move_node function.

EDIT : I have the same problem with "add" from the contextmenu

Someone can help me ?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

旧瑾黎汐 2024-12-12 17:41:44

来自 jsTree 文档:

http://www.jstree.com/documentation/html_data

将根据节点结构应用三个类之一:

<li class="[ jstree-open | jstree-closed | jstree-leaf ]"> 

Jonathan Stowell 是对的,但将 attr.class 设置为“jstree-leaf”将不起作用(至少在最新版本上不起作用)。

但是“open”和“close”让我想起了node.state,所以我尝试了一下,结果发现当你在JSON序列化类中将node.state设置为“leaf”时,它将是不可扩展。

From the jsTree documentation:

http://www.jstree.com/documentation/html_data

one of the three classes will be applied depending on node structure :

<li class="[ jstree-open | jstree-closed | jstree-leaf ]"> 

Jonathan Stowell is right, but setting attr.class to "jstree-leaf" won't work (at least not on the latest version).

But "open" and "closed" reminded me of node.state, so I tried, and it turned out that when you set node.state to "leaf" in your JSON serialzation class, it will be non-expandable.

苄①跕圉湢 2024-12-12 17:41:44

我将 jstree-leaf 类添加到没有子节点的 attr 属性中。

attr: { "class" : "jstree-leaf" }

然后,这将设置您需要的 CSS 类,使其不具有扩展功能。

I added the jstree-leaf class to the attr property for my nodes that do not have children.

attr: { "class" : "jstree-leaf" }

This then sets the CSS class you need to not have the expand feature.

我是男神闪亮亮 2024-12-12 17:41:44

我对“创建”方法和没有子节点的节点也有同样的问题。解决了将此类节点的状态指定为“打开”而不是默认的“关闭”的问题。

希望这有帮助。

I had the same problem with "create" method and nodes without children. Solved it specifying such nodes' state as "open" instead of the default "closed".

Hopes this helps.

手心的温暖 2024-12-12 17:41:44

如果发送 json 数据,请将“jstree-leaf”作为 li_attr 的类

 li_attr: {class = "jstree-leaf" }

if you send json data, give "jstree-leaf" as li_attr's class

 li_attr: {class = "jstree-leaf" }
梅窗月明清似水 2024-12-12 17:41:44

返回 JSON 对象时,如果该节点没有子节点,请将 children 属性设置为 false 并将 state 属性设置为 假。

When you return the JSON object, if the node does not have children, set the children property to false and set the state property to false.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文