- VaR tree = ext. tree;
- VaR tree = NULL;
- Ext. onready (function (){
- Tree = new tree. treepanel ({
- El: 'tree-Div ',
- Onlyleafcheckable: false,
- Rootvisible: True,
- Autoscroll: True,
- Animate: false, // whether to animation
- Enabledd: True, // whether drag/drop is supported
- Containerscroll: True,
- Lines: True,
- Checkmodel: 'cascade ',
- Loader: new tree. treeloader ({dataurl: '../INFO/RSS. do? Method = getjsonarray ',
- Baseattrs: {uiprovider: Ext. Tree. treechecknodeui}
- })
- });
- // Set the root node
- VaR root = new tree. asynctreenode (
- {
- "Text": "My network address ",
- "ID": "01 ",
- "Allowdrag": false // false indicates that the file cannot be dragged.
- }
- );
- // Events before binding nodes to load
- Tree. On ('beforeload', function (node ){
- If (node. ID! = '01 '){
- Tree. loader. dataurl = '../INFO/RSS. do? Method = getchildjsonarray & nodeid = '+ node. ID;
- }
- });
- // Bind node Click Event
- /**//*
- Tree. On ('click', function (node ){
- If (node. ID! = 'Root '){
- Alert (node. ID );
- Alert (node. Text );
- Alert (node. href );
- }
- });
- */
- // Bind the node drag event, find the implementation of Tree node drag for a long time, and finally find this implementation in the post of a foreigner. After dragging, the required information has been captured, you can drag a tree by adding functions linked to the background.
- Tree. On ('nodedrop ',
- Function (e ){
- If (E. Point = 'append '){
- Alert ('current "['+ E. dropnode. Text +']" is put under the directory "'Folder e.tar get. Text +! ');
- VaR resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID +" & parentrootid = "paie.tar get. ID +" & type = APPEND ";
- VaR resulthtml = xmlhttphelper. Transmit (false, "get", "text", resulturl, null, null );
- }
- Else if (E. Point = 'ababove '){
- // Alert ('current "'+ E. dropnode. Text +'" is placed on "'your e.tar get. Text +! ');
- VaR resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID +" & parentrootid = "paie.tar get. ID +" & type = above ";
- VaR resulthtml = xmlhttphelper. Transmit (false, "get", "text", resulturl, null, null );
- } Else if (E. Point = 'below '){
- // Alert ('current "'+ E. dropnode. Text +'" is placed under "'your e.tar get. Text +! ');
- VaR resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID +" & parentrootid = "paie.tar get. ID +" & type = below ";
- VaR resulthtml = xmlhttphelper. Transmit (false, "get", "text", resulturl, null, null );
- }
- }
- );
- // Right-click the binding node and choose menu
- Tree. On ('textmenu ', function (node, event ){
- // Alert ("node. ID =" + node. ID );
- Event. preventdefault (); // This line is required
- Rightclick. showat (event. getxy (); // obtain the coordinates of the mouse and click to display the menu
- // Alert (node. ID );
- Document. getelementbyid ('rootid'). value = node. ID;
- });
- // Right-click the menu
- VaR rightclick = new Ext. Menu. menu ({
- ID: 'rightclickcont ',
- Items :[{
- ID: 'rmenu1 ',
- Text: 'editor ',
- // Add a menu Click Event
- Handler: function (node ){
- // Alert (node. dropnode. ID );
- }
- },{
- ID: 'rmenu2 ',
- Text: 'delete'
- },{
- ID: 'rmenu3 ',
- Text: 'menu 3'
- }]
- });
- Tree. setrootnode (Root );
- // Render the tree
- Tree. Render ();
- Root. Expand ();
- });
VaR tree = ext. tree; var tree = NULL; Ext. onready (function () {tree = new tree. treepanel ({El: 'tree-Div ', onlyleafcheckable: false, rootvisible: True, autoscroll: True, animate: false, // whether to animated enabledd: True, // whether to drag and drop containerscroll: True, lines: True, checkmodel: 'cascade ', loader: new tree. treeloader ({dataurl :'.. /INFO/RSS. do? Method = getjsonarray ', baseattrs: {uiprovider: ext. tree. treechecknodeui}); // set the root node var root = new tree. asynctreenode ({"text": "", "ID": "01", "allowdrag": false // false indicates that the object cannot be dragged }); // bind the node to load the previous event tree. on ('beforeload', function (node) {If (node. ID! = '01') {tree. loader. dataurl = '../INFO/RSS. do? Method = getchildjsonarray & nodeid = '+ node. id ;}}); // click event/** // * tree for binding nodes. on ('click', function (node) {If (node. ID! = 'Root') {alert (node. ID); alert (node. text); alert (node. href) ;}}); * // bind a node drag event, find the implementation of Tree node drag for a long time, and finally find this implementation in the post of a foreigner, after dragging, the required information has been captured. You can drag the tree by adding the function associated with the background. on ('nodedrop', function (e) {If (E. point = 'append') {alert ('current "['+ E. dropnode. text + '] "put to the directory" folder 'Folder e.tar get. text +! '); Var resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID + "& parentrootid =" paie.tar get. ID + "& type = APPEND"; var resulthtml = xmlhttphelper. transmit (false, "get", "text", resulturl, null, null);} else if (E. point = 'ababove ') {// alert ('current "' + E. dropnode. text + '"is placed in" 'your e.tar get. text + '"above! '); Var resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID + "& parentrootid =" paie.tar get. ID + "& type = above"; var resulthtml = xmlhttphelper. transmit (false, "get", "text", resulturl, null, null);} else if (E. point = 'below') {// alert ('current "'+ E. dropnode. text + '"is placed in" 'your e.tar get. text +! '); Var resulturl = "../INFO/RSS. do? Method = treenodetuodong & currenrootid = "+ E. dropnode. ID + "& parentrootid =" paie.tar get. ID + "& type = below"; var resulthtml = xmlhttphelper. transmit (false, "get", "text", resulturl, null, null) ;}}); // right-click the binding node and choose the function tree. on ('textmenu ', function (node, event) {// alert ("node. id = "+ node. ID); event. preventdefault (); // This line is required. showat (event. getxy (); // get the coordinates of the mouse and click to display the menu // alert (node. ID); document. getelementbyid ('rootid '). value = node. ID;}); // right-click the menu var rightclick = new Ext. menu. menu ({ID: 'rightclickcont', items: [{ID: 'rmenu1', text: 'edit', // Add a menu Click Event Handler: function (node) {// alert (node. dropnode. ID) ;}},{ ID: 'rmenu2 ', text: 'delete' },{ ID: 'rmenu3', text: 'menu 3'}]}); tree. setrootnode (Root); // render the tree. render (); root. expand ();});
Original post address: http://www.cnblogs.com/huazi4995/articles/1245150.html