保存到桌面加入收藏设为首页
EasyUI
当前位置:首页 > Web技术 > EasyUI

easyui创建异步树(Async Tree)

时间:2013-07-26 01:52:24   作者:梦幻小纯哥   来源:永硕E盘装饰网   阅读:707   评论:0
内容摘要:CreateAsyncTree创建异步树TocreateAsyncTree,everytreenodemusthasa'id'attributethatwillbepostedtobackservertoretrievechildrennodesdata.创建异步树,每棵树节点必...

 

Create Async Tree

创建异步树

 

To create Async Tree, every tree node must has a 'id' attribute that will be posted to back server to retrieve children nodes data.

创建异步树,每棵树节点必须 一个“id”属性, id将被 给服务器检索数据的子节点。

 

异步树的效果如下:

easyui创建异步树(Async_Tree)

 

 

Create Tree

创建树

<ul id="tt" class="easyui-tree"

              url="tree2_getdata.php">

</ul>

 

 

The Server Code

服务端代码

 

<?php

 

$id = isset($_POST['id']) ? intval($_POST['id']) : 0;

 

include 'conn.php';

 

$result = array();

$rs = mysql_query("select * from nodes where parentId=$id");

while($row = mysql_fetch_array($rs)){

       $node = array();

       $node['id'] = $row['id'];

       $node['text'] = $row['name'];

       $node['state'] = has_child($row['id']) ? 'closed' : 'open';

       array_push($result,$node);

}

 

echo json_encode($result);

 

function has_child($id){

       $rs = mysql_query("select count(*) from nodes where parentId=$id");

       $row = mysql_fetch_array($rs);

       return $row[0] > 0 ? true : false;

}

 

?>

 

 



标签:创建  异步  
相关评论