Upgrade to ExtJS 4.0.2 - Released 06/09/2011
[extjs.git] / examples / tree / reorder.js
index b0b5cc0..8866574 100644 (file)
@@ -1,32 +1,69 @@
-/*!
- * Ext JS Library 3.3.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',
+/*
+
+This file is part of Ext JS 4
+
+Copyright (c) 2011 Sencha Inc
+
+Contact:  http://www.sencha.com/contact
+
+GNU General Public License Usage
+This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file.  Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
 
+If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
+
+*/
+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: {
-            nodeType: 'async',
             text: 'Ext JS',
-            draggable: false,
-            id: 'src'
-        }
+            id: 'src',
+            expanded: true
+        },
+        folderSort: true,
+        sorters: [{
+            property: 'text',
+            direction: 'ASC'
+        }]
+    });
+
+    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();
+                }
+            }]
+        }]
     });
+});
 
-    // render the tree
-    tree.render('tree-div');
-    tree.getRootNode().expand();
-});
\ No newline at end of file