Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / examples / tree / two-trees.js
1 /*!
2  * Ext JS Library 3.2.0
3  * Copyright(c) 2006-2010 Ext JS, Inc.
4  * licensing@extjs.com
5  * http://www.extjs.com/license
6  */
7 var TreeTest = function(){
8     // shorthand
9     var Tree = Ext.tree;
10     
11     return {
12         init : function(){
13             // yui-ext tree
14             var tree = new Tree.TreePanel({
15                 animate:true, 
16                 autoScroll:true,
17                 loader: new Tree.TreeLoader({dataUrl:'get-nodes.php'}),
18                 enableDD:true,
19                 containerScroll: true,
20                 border: false,
21                 width: 250,
22                 height: 300,
23                 dropConfig: {appendOnly:true}
24             });
25             
26             // add a tree sorter in folder mode
27             new Tree.TreeSorter(tree, {folderSort:true});
28             
29             // set the root node
30             var root = new Tree.AsyncTreeNode({
31                 text: 'Ext JS', 
32                 draggable:false, // disable root node dragging
33                 id:'src'
34             });
35             tree.setRootNode(root);
36             
37             // render the tree
38             tree.render('tree');
39             
40             root.expand(false, /*no anim*/ false);
41             
42             //-------------------------------------------------------------
43             
44             // ExtJS tree            
45             var tree2 = new Tree.TreePanel({
46                 animate:true,
47                 autoScroll:true,
48                 //rootVisible: false,
49                 loader: new Ext.tree.TreeLoader({
50                     dataUrl:'get-nodes.php',
51                     baseParams: {path:'extjs'} // custom http params
52                 }),
53                 containerScroll: true,
54                 border: false,
55                 width: 250,
56                 height: 300,
57                 enableDD:true,
58                 dropConfig: {appendOnly:true}
59             });
60             
61             // add a tree sorter in folder mode
62             new Tree.TreeSorter(tree2, {folderSort:true});
63             
64             // add the root node
65             var root2 = new Tree.AsyncTreeNode({
66                 text: 'Extensions', 
67                 draggable:false, 
68                 id:'ux'
69             });
70             tree2.setRootNode(root2);
71             tree2.render('tree2');
72             
73             root2.expand(false, /*no anim*/ false);
74         }
75     };
76 }();
77
78 Ext.EventManager.onDocumentReady(TreeTest.init, TreeTest, true);