По просьбам трудящихся….яваскрипт:
<html>
<head>
<title>Test Task Window</title>
<link rel="stylesheet" type="text/css" href="../ext-4.0.1/resources/css/ext-all.css">
<script type="text/javascript" src="../ext-4.0.1/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../ext-4.0.1/ext-all-debug.js"></script>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function() {
var store = Ext.create('Ext.data.TreeStore', {
proxy: {
type: 'ajax',
url: 'Nodes.php'
},
root: {
text: 'TaskTree',
id: 'RId',
expanded: true
},
storeId: 'MyStore',
folderSort: true,
sorters: [{
property: 'text',
direction: 'ASC'
}],
listeners: {
load: {
fn: function(stor, rec, res){
console.log(stor);
console.log(rec);
console.log(res);
}
}
}
});
var tree = new Ext.tree.TreePanel({
id: 'tree',
store: store,
useArrows: true,
editable: true,
animate: true,
autoScroll: true,
});
new Ext.window.Window({
title: 'Window for Tree',
height: 200,
width: 250,
items: [tree]
}).show();
});
</script>
</body>
</html>
<?php
class TreeNode {
public $text = "";
public $id = "";
public $iconCls = "";
public $leaf = true;
public $draggable = false;
public $href = "#";
public $hrefTarget = "";
function __construct($id,$text,$iconCls,$leaf,$draggable,
$href,$hrefTarget) {
$this->id = $id;
$this->text = $text;
$this->iconCls = $iconCls;
$this->leaf = $leaf;
$this->draggable = $draggable;
$this->href = $href;
$this->hrefTarget = $hrefTarget;
}
}
class TreeNodes {
protected $nodes = array();
function add($id,$text,$iconCls,$leaf,$draggable,
$href,$hrefTarget) {
$n = new TreeNode($id,$text,$iconCls,$leaf,
$draggable,$href,$hrefTarget);
$this->nodes[] = $n;
}
function toJson() {
return json_encode($this->nodes);
}
}
$requestedNode = "";
if (isset($_REQUEST["node"])) {
$requestedNode = $_REQUEST["node"];
}
$treeNodes = new TreeNodes();
//if ('rootId' == $requestedNode) {
$treeNodes->add("node-datasources","Datasources","",false,false,"","");
$treeNodes->add("node-reports","Reports","",false,false,"","");
/*} else if ('node-datasources' == $requestedNode) {
$treeNodes->add("employees-system-node","Employee Management System","datasource",true,false,"","");
$treeNodes->add("customers-system-node","Customer Management System","datasource",true,false,"","");
$treeNodes->add("order-system-node","Order Processing System","datasource",true,false,"","");
} else if ('node-reports' == $requestedNode) {
$treeNodes->add("time-report-node","Time and Attendance","report",true,false,"","");
$treeNodes->add("orders-by-quarter-report-node","Orders By Quarter","report",true,false,"","");
$treeNodes->add("customers-trends-report-node","Customer Trends","report",true,false,"","");
}
*/
echo $treeNodes->toJson();
?>