Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / examples / tree / reorder.js
index 6f0464f..7d31150 100644 (file)
@@ -1,32 +1,54 @@
-/*!
- * Ext JS Library 3.2.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-Ext.onReady(function(){
-    // shorthand
-    var Tree = Ext.tree;
-
-    var tree = new Tree.TreePanel({
-        useArrows: true,
-        autoScroll: true,
-        animate: true,
-        enableDD: true,
-        containerScroll: true,
-        border: false,
-        // auto create TreeLoader
-        dataUrl: 'get-nodes.php',
+Ext.require([
+    'Ext.tree.*',
+    'Ext.data.*',
+    'Ext.tip.*'
+]);
 
 
+Ext.onReady(function() {
+    Ext.QuickTips.init();
+    
+    var store = Ext.create('Ext.data.TreeStore', {
+        proxy: {
+            type: 'ajax',
+            url: 'get-nodes.php'
+        },
         root: {
         root: {
-            nodeType: 'async',
             text: 'Ext JS',
             text: 'Ext JS',
-            draggable: false,
-            id: 'src'
-        }
+            id: 'src',
+            expanded: true
+        },
+        folderSort: true,
+        sorters: [{
+            property: 'text',
+            direction: 'ASC'
+        }]
     });
 
     });
 
-    // render the tree
-    tree.render('tree-div');
-    tree.getRootNode().expand();
-});
\ No newline at end of file
+    var tree = Ext.create('Ext.tree.Panel', {
+        store: store,
+        viewConfig: {
+            plugins: {
+                ptype: 'treeviewdragdrop'
+            }
+        },
+        renderTo: 'tree-div',
+        height: 300,
+        width: 250,
+        title: 'Files',
+        useArrows: true,
+        dockedItems: [{
+            xtype: 'toolbar',
+            items: [{
+                text: 'Expand All',
+                handler: function(){
+                    tree.expandAll();
+                }
+            }, {
+                text: 'Collapse All',
+                handler: function(){
+                    tree.collapseAll();
+                }
+            }]
+        }]
+    });
+});