two-trees.js
上传用户:shuoshiled
上传日期:2018-01-28
资源大小:10124k
文件大小:2k
源码类别:

中间件编程

开发平台:

JavaScript

  1. /*!  * Ext JS Library 3.0.0  * Copyright(c) 2006-2009 Ext JS, LLC  * licensing@extjs.com  * http://www.extjs.com/license  */ var TreeTest = function(){
  2.     // shorthand
  3.     var Tree = Ext.tree;
  4.     
  5.     return {
  6.         init : function(){
  7.             // yui-ext tree
  8.             var tree = new Tree.TreePanel({
  9.                 animate:true, 
  10.                 autoScroll:true,
  11.                 loader: new Tree.TreeLoader({dataUrl:'get-nodes.php'}),
  12.                 enableDD:true,
  13.                 containerScroll: true,
  14.                 border: false,
  15.                 dropConfig: {appendOnly:true}
  16.             });
  17.             
  18.             // add a tree sorter in folder mode
  19.             new Tree.TreeSorter(tree, {folderSort:true});
  20.             
  21.             // set the root node
  22.             var root = new Tree.AsyncTreeNode({
  23.                 text: 'Ext JS', 
  24.                 draggable:false, // disable root node dragging
  25.                 id:'src'
  26.             });
  27.             tree.setRootNode(root);
  28.             
  29.             // render the tree
  30.             tree.render('tree');
  31.             
  32.             root.expand(false, /*no anim*/ false);
  33.             
  34.             //-------------------------------------------------------------
  35.             
  36.             // YUI tree            
  37.             var tree2 = new Tree.TreePanel({
  38.                 animate:true,
  39.                 autoScroll:true,
  40.                 //rootVisible: false,
  41.                 loader: new Ext.tree.TreeLoader({
  42.                     dataUrl:'get-nodes.php',
  43.                     baseParams: {lib:'yui'} // custom http params
  44.                 }),
  45.                 containerScroll: true,
  46.                 border: false,
  47.                 enableDD:true,
  48.                 dropConfig: {appendOnly:true}
  49.             });
  50.             
  51.             // add a tree sorter in folder mode
  52.             new Tree.TreeSorter(tree2, {folderSort:true});
  53.             
  54.             // add the root node
  55.             var root2 = new Tree.AsyncTreeNode({
  56.                 text: 'My Files', 
  57.                 draggable:false, 
  58.                 id:'yui'
  59.             });
  60.             tree2.setRootNode(root2);
  61.             tree2.render('tree2');
  62.             
  63.             root2.expand(false, /*no anim*/ false);
  64.         }
  65.     };
  66. }();
  67. Ext.EventManager.onDocumentReady(TreeTest.init, TreeTest, true);