- 注册时间
- 2023-5-22
- 最后登录
- 2023-5-24
- 阅读权限
- 10
- 积分
- 21
- 精华
- 0
- 帖子
- 2
|
小弟最近要用lazytree,因为项目原因不可以用url,需要用loadList绑定数据,但是在 onbeforeload="onBeforeTreeLoad"的时候一直死循环,不知道怎么处理,麻烦帮忙看看,下面是源代码,其中getFileForlderURL,getFileForlderByParentForldId是我方erp的api接口地址。
- <html>
- <head>
- <title></title>
- <meta charset="utf-8" />
- <script src="website/res/js/boot.js" type="text/javascript"></script>
- <!-- <script src="website/res/constant.js" type="text/javascript"></script> -->
- <script src="website/res/js/common.js" type="text/javascript"></script>
- <link href="website/res/frame.css" rel="stylesheet" type="text/css" />
- <link href="website/res/index.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="form1">
- <div class="navbar">
- <div class="navbar-header">
- <div class="navbar-brand"></div>
- </div>
- </div>
- <div id="layout1" class="mini-layout" style="width:100%;height:100%;">
- <div title="文件夹" region="west" width="300" showSplitIcon="true">
- <ul id="tree1" class="mini-tree" style="padding:5px;" showTreeIcon="true" textField="FNAME"
- idField="id" parentField="parentid_id" resultAsTree="false" onbeforeload="onBeforeTreeLoad"
- expandOnNodeClick="true" expandOnLoad="0">
- </ul>
- </div>
-
- </div>
- <script type="text/javascript">
-
- mini.parse();
-
- //tree
- function firstTreeLoad() {
- var jsonObj =
- {
- "parameter": "parameter"
- }
- //加载文件夹树
- mydata = null;
- fnWebApiClient(getFileForlderURL, jsonObj)
- if (mydata != null && mydata.length > 0) {
- mini.get("tree1").loadList(mydata);
- }
- }
- firstTreeLoad();
-
- /*
- 上面结果数据如下:
-
- {id: 101239, parentid_id: 0, FNAME: '研究院[2]', isLeaf: 0, expanded: 0, …}
- {id: 101240, parentid_id: 0, FNAME: '物料申请单[4]', isLeaf: 0, expanded: 0, …}
- {id: 101241, parentid_id: 0, FNAME: 'BOM[2]', isLeaf: 0, expanded: 0, …}
- {id: 130201, parentid_id: 0, FNAME: '培训文档[5]', isLeaf: 0, expanded: 0, …}
- {id: 130203, parentid_id: 0, FNAME: '产品文件[3]', isLeaf: 0, expanded: 0, …}
- {id: 134274, parentid_id: 0, FNAME: '项目模板[1]', isLeaf: 0, expanded: 0, …}
- {id: 134275, parentid_id: 0, FNAME: '公司项目[1]', isLeaf: 0, expanded: 0, …}
-
- {id: 135009, parentid_id: 0, FNAME: '设计变更[2]', isLeaf: 0, expanded: 0, …}
- */
- //lazytree
- function onBeforeTreeLoad(e) {
- // var tree = e.sender; //树控件
- var node = e.node; //当前节点
- // var params = e.params; //参数对象
- //可以传递自定义的属性
- // params.parameter = node.id; //后台:request对象获取"myField"
- // var levelnode = tree.getAncestors(e.node);//获取该节点所有父节点
- var jsonObj =
- {
- "parameter": node.id
- }
- //加载文件夹树
- mydata = null;
- fnWebApiClient(getFileForlderByParentForldId, jsonObj)
- if (mydata != null && mydata.length > 0)
- mini.get("tree1").loadNode(mydata);
- }
- /*
- 上面结果数据如下:
-
- {id: 101242, parentid_id: 101239, FNAME: '设计图纸[2]', isLeaf: 0, expanded: 0, …}
-
- {id: 101243, parentid_id: 101239, FNAME: '一般文档[2]', isLeaf: 0, expanded: 0, …}
- {id: 101244, parentid_id: 101239, FNAME: 'BOM(结构设计部)[2]', isLeaf: 0, expanded: 0, …}
- */
-
- </script>
- </body>
- </html>
复制代码
|
|