文档半岛外围网上直营>>jQuery EasyUI使用教程>>jQuery EasyUI使用教程:创建异步树
jQuery EasyUI使用教程:创建异步树
Kendo UI for jQuery——创建现代Web应用程序的最完整UI库!查看详情>>>
想要创建异步,每个树节点必须要有一个“id”属性,此属性将提交回服务器去检索子节点的数据。

创建树
<ul id="tt" class="easyui-tree" url="tree2_getdata.php"> </ul>
服务器代码
$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;
}
下载EasyUI示例:


QQ交谈
在线咨询

渝公网安备
50010702500608号

客服热线