ColdFusion MX应用实倒
CFTREE数据库应用实例
<html>
<head>
<title>CFTREE数据库应用实例-CFMCHINA.COM</title>
</head>
<body>
调用数据库,列出树
<cfform>
<!--查询数据库-->
<cfquery name="GetEmployees"
datasource="cftreetest">
SELECT
EmployeeID AS ItemID,
ManagerID AS ParentItemID,
Name AS Description
FROM
Employees
ORDER BY
Name
</cfquery>
<!-- 列出树-->
<cftree name="EmployeeID"
height="250"
width="200"
lookandfeel="METAL">
<cfloop query="GetEmployees">
<cftreeitem value="#ItemID#"
display="#Description#"
parent="#ParentItemID#">
</cfloop>
</cftree>
</cfform>
</body>
</html>
注:
数据库表:Employees
字段:
ID 自动编号
EmployeeID item项目值
ManagerID ParentItemID项目值
Name 项目名称