jQuery MiniUI

标题: Tree LazyTree 懒加载树形 BUG [打印本页]

作者: 3078825    时间: 2013-3-12 14:20:51     标题: Tree LazyTree 懒加载树形 BUG

本帖最后由 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?


作者: factory    时间: 2013-3-12 15:09:17

是你else里的$name拼接错了吧
你试试把"$name\" 替换成".$name.\"试试呢
作者: 3078825    时间: 2013-3-12 15:18:16

factory 发表于 2013-3-12 15:09
是你else里的$name拼接错了吧
你试试把"$name\" 替换成".$name.\"试试呢

斜杠是PHP的转义而已。跟这个没关系。
PHP是正常输入我例子中的json文件的
作者: factory    时间: 2013-3-12 15:30:17

3078825 发表于 2013-3-12 15:18
斜杠是PHP的转义而已。跟这个没关系。
PHP是正常输入我例子中的json文件的 ...

那肯定是你返回的json字符串里面有问题了,json不正确
如果用.$name.去拼接一个字符串的话,我试了,是可以正常显示的
作者: 3078825    时间: 2013-3-12 15:37:01

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

但我仅仅是父类是message的时候不能可以加载下级树,别的名称的父类都可以加载下级树
我看了返回的json没有问题
作者: 3078825    时间: 2013-3-12 15:43:34

本帖最后由 3078825 于 2013-3-12 15:46 编辑

我打包个上来吧你测试下。
[attach]1439[/attach]

[attach]1440[/attach]

就是名字为message的节点打不开,别的都正常
下载最新的2.1.8版本也不行

作者: factory    时间: 2013-3-12 15:55:13

3078825 发表于 2013-3-12 15:43
我打包个上来吧你测试下。

你上面给的数据我在本地已经试过了,我换成是.$name.这种方式是可以正常显示的,说明你原来的echo的json字符串不正确啊。
作者: 3078825    时间: 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. ?>
复制代码



作者: factory    时间: 2013-3-12 16:32:30

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

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




欢迎光临 jQuery MiniUI (http://miniui.com/discuss/) Powered by Discuz! X2