Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / tree / xml-tree.js
diff --git a/examples/tree/xml-tree.js b/examples/tree/xml-tree.js
new file mode 100644 (file)
index 0000000..1114539
--- /dev/null
@@ -0,0 +1,51 @@
+Ext.require([
+    'Ext.tree.*',
+    'Ext.data.*'
+]);
+
+Ext.onReady(function() {
+
+    var store = Ext.create('Ext.data.TreeStore', {
+        proxy: {
+            type: 'ajax',
+            url: 'get-nodes.php',
+            extraParams: {
+                isXml: true
+            },
+            reader: {
+                type: 'xml',
+                root: 'nodes',
+                record: 'node'
+            }
+        },
+        sorters: [{
+            property: 'leaf',
+            direction: 'ASC'
+        },{
+            property: 'text',
+            direction: 'ASC'
+        }],
+        root: {
+            text: 'Ext JS',
+            id: 'src',
+            expanded: true
+        }
+    });
+
+    // create the Tree
+    var tree = Ext.create('Ext.tree.Panel', {
+        store: store,
+        hideHeaders: true,
+        rootVisible: true,
+        viewConfig: {
+            plugins: [{
+                ptype: 'treeviewdragdrop'
+            }]
+        },
+        height: 350,
+        width: 400,
+        title: 'Directory Listing',
+        renderTo: 'tree-example',
+        collapsible: true
+    });
+});