jQuery MiniUI

 找回密码
 立即注册
查看: 5340|回复: 8
打印 上一主题 下一主题

Tree LazyTree 懒加载树形 BUG [复制链接]

Rank: 2

跳转到指定楼层
楼主
发表于 2013-3-12 14:20:51 |只看该作者 |倒序浏览
本帖最后由 3078825 于 2013-3-12 14:38 编辑

LazyTree 懒加载树形当父节点存在节点名称(ID)为message的节点时,子节点无法加载
测试代码
  1. <ul id="table_tree" class="mini-tree" showTreeIcon="true" leafIcon="mini-tree-folder" showTreeIcon="true" textField="name" onbeforeload="onBeforeTreeLoad" onbeforeexpand="onBeforeExpand" idField="name" parentField="pid" resultAsTree="false"></ul>


  2. <script type="text/javascript">
  3.     mini.parse();
  4.     function onBeforeExpand(e) {
  5.         var tree = e.sender;
  6.         var nowNode = e.node;
  7.         var root = tree.getRootNode();

  8.         tree.cascadeChild(root, function (node) {
  9.             if (tree.isExpandedNode(node)) {
  10.                 if (node != nowNode && !tree.isAncestor(node, nowNode)) {
  11.                     tree.collapseNode(node, true);
  12.                 }
  13.             }
  14.         });

  15.     }
  16.     function onBeforeTreeLoad(e) {
  17.         var tree = e.sender;    //树控件
  18.         var node = e.node;      //当前节点
  19.         var params = e.params;  //参数对象
  20.     }
  21.     mini.get('table_tree').load("/tree.php");
  22. </script>
复制代码

PHP代码:
  1. <?php
  2. $name = empty($_REQUEST['name']) ? '' : trim($_REQUEST['name']);
  3. if(empty($name))
  4. {
  5.         echo '[{"id":1,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin"},{"id":2,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin_group"},{"id":3,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"loginlog"},{"id":4,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"message"},{"id":5,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"module"},{"id":6,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"session"},{"id":7,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"weather"}]';
  6. }
  7. else
  8. {
  9.         echo "[{\"id\":1,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"id\"},{\"id\":2,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"tuid\"},{\"id\":3,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"tfullname\"},{\"id\":4,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"uid\"},{\"id\":5,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"ufullname\"},{\"id\":6,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"message\"},{\"id\":7,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"date\"},{\"id\":8,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"status\"},{\"id\":9,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"tdel\"},{\"id\":10,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"$name\",\"folder\":0,\"name\":\"udel\"}]";
  10. }
  11. ?>
复制代码




父级json
  1. [{"id":1,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin"},{"id":2,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin_group"},{"id":3,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"loginlog"},{"id":4,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"message"},{"id":5,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"module"},{"id":6,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"session"},{"id":7,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"weather"}]
复制代码
message 节点json
  1. [{"id":1,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"id"},{"id":2,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"tuid"},{"id":3,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"tfullname"},{"id":4,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"uid"},{"id":5,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"ufullname"},{"id":6,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"message"},{"id":7,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"date"},{"id":8,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"status"},{"id":9,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"tdel"},{"id":10,"isLeaf":true,"type":"txt","pid":"message","folder":0,"name":"udel"}]
复制代码


只有父级为message的节点不能展开,如果我把父级的message改成messagex就可以问题。
是不是父节点不能命名为message?

Rank: 8Rank: 8

沙发
发表于 2013-3-12 15:09:17 |只看该作者
是你else里的$name拼接错了吧
你试试把"$name\" 替换成".$name.\"试试呢

Rank: 2

板凳
发表于 2013-3-12 15:18:16 |只看该作者
factory 发表于 2013-3-12 15:09
是你else里的$name拼接错了吧
你试试把"$name\" 替换成".$name.\"试试呢

斜杠是PHP的转义而已。跟这个没关系。
PHP是正常输入我例子中的json文件的

Rank: 8Rank: 8

地板
发表于 2013-3-12 15:30:17 |只看该作者
3078825 发表于 2013-3-12 15:18
斜杠是PHP的转义而已。跟这个没关系。
PHP是正常输入我例子中的json文件的 ...

那肯定是你返回的json字符串里面有问题了,json不正确
如果用.$name.去拼接一个字符串的话,我试了,是可以正常显示的

Rank: 2

5#
发表于 2013-3-12 15:37:01 |只看该作者
factory 发表于 2013-3-12 15:30
那肯定是你返回的json字符串里面有问题了,json不正确
如果用.$name.去拼接一个字符串的话,我试了,是可 ...

但我仅仅是父类是message的时候不能可以加载下级树,别的名称的父类都可以加载下级树
我看了返回的json没有问题

Rank: 2

6#
发表于 2013-3-12 15:43:34 |只看该作者
本帖最后由 3078825 于 2013-3-12 15:46 编辑

我打包个上来吧你测试下。




就是名字为message的节点打不开,别的都正常
下载最新的2.1.8版本也不行
附件: 你需要登录才可以下载或查看附件。没有帐号?立即注册

Rank: 8Rank: 8

7#
发表于 2013-3-12 15:55:13 |只看该作者
3078825 发表于 2013-3-12 15:43
我打包个上来吧你测试下。

你上面给的数据我在本地已经试过了,我换成是.$name.这种方式是可以正常显示的,说明你原来的echo的json字符串不正确啊。

Rank: 2

8#
发表于 2013-3-12 16:02:42 |只看该作者
本帖最后由 3078825 于 2013-3-12 16:07 编辑
factory 发表于 2013-3-12 15:55
你上面给的数据我在本地已经试过了,我换成是.$name.这种方式是可以正常显示的,说明你原来的echo的json ...

但为什么别的节点能打开呢。。?你下载我的压缩包,在能运行PHP的环境运行下就明白了。
我的确试了不行
按你说的改了也是不行的。

  1. <?php
  2. $name = empty($_REQUEST['name']) ? '' : trim($_REQUEST['name']);
  3. if(empty($name))
  4. {
  5.         echo '[{"id":1,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin"},{"id":2,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"admin_group"},{"id":3,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"loginlog"},{"id":4,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"message"},{"id":5,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"module"},{"id":6,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"session"},{"id":7,"isLeaf":false,"type":null,"pid":-1,"folder":1,"name":"weather"}]';
  6. }
  7. else
  8. {
  9.         echo "[{\"id\":1,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"id\"},{\"id\":2,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"tuid\"},{\"id\":3,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"tfullname\"},{\"id\":4,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"uid\"},{\"id\":5,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"ufullname\"},{\"id\":6,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"message\"},{\"id\":7,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"date\"},{\"id\":8,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"status\"},{\"id\":9,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"tdel\"},{\"id\":10,\"isLeaf\":true,\"type\":\"txt\",\"pid\":\"".$name."\",\"folder\":0,\"name\":\"udel\"}]";
  10. }
  11. ?>
复制代码


Rank: 8Rank: 8

9#
发表于 2013-3-12 16:32:30 |只看该作者
3078825 发表于 2013-3-12 16:02
但为什么别的节点能打开呢。。?你下载我的压缩包,在能运行PHP的环境运行下就明白了。
我的确试了不行
按 ...

恩,我这边也看下
另外,建议你用简单点的数据测试问题。1-2个节点就够了,没问题了再增加节点,不然过多的数据不好查看问题,尤其是字符串里面的问题

Archiver|普加软件

GMT+8, 2024-11-27 22:43 , Processed in 1.040819 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部