Здравствуйте, я только начинаю изучать Ext JS. Задумал тут сделать дерево, чтобы подгружать узлы с удаленного сервера. Но не выходит, просмотрел кучу примеров, доки от Sencha...но все равно не получается, а главное не пойму что я не так делаю. Помогите разобраться что к чему.
Код index.html
| Код | <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> <script type="text/javascript"> Ext.onReady(function() { var tree = new Ext.tree.TreePanel({ id: 'tree', useArrows: true, animate: true, autoScroll: true, url: 'Nodes.php', root: { nodeType: 'async', text: 'TaskTree', id: 'rootId' }, listeners: { beforeload: { fn: function(){alert('Load begin!');} }, } }); new Ext.window.Window({ title: 'Window for Tree', height: 200, width: 250, items: [tree] }).show(); });
</script> </head> <body> </body> </html>
|
А вот код Php файла...проверял, php отправляет то что нужно...видимо ошибка в javascript.
| Код | <?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(); ?>
|
|