ExtJS 4.2 Right-click menu tree Node (, select Inverse, repeal)

Source: Internet
Author: User

Write your own latest version number extjs4.2 tree node operation, record it, may be used in the future.

var tree = new Ext.tree.TreePanel ({flex:1,animate:true, Autoscroll:true,anchor: ' 100% 93% ', Store:new Ext.data.TreeSto Re ({root:{expanded:true,text: ' A ', Children:[{expanded:true,text: ' 1 ', Children:[{text: ' 2 ', Icon: ' sysimg/icon/ Image.gif ', Leaf:true,id: ' 1_1 ', Checked:false},{text: ' 3 ', Icon: ' Sysimg/icon/layout.gif ', Leaf:true,id: ' 1_2 ', Checked:false},{text: ' 4 ', Icon: ' Sysimg/icon/image_add.png ', Leaf:true,id: ' 1_3 ', Checked:false},{text: ' 5 ', Icon: ' Sysimg/icon/out.gif ', Leaf:true,id: ' 1_4 ', Checked:false},{text: ' 6 ', Icon: ' Sysimg/icon/leave.gif ', Leaf:true,id: ' 1_ 5 ', Checked:false},{text: ' 7 ', Icon: ' Sysimg/icon/preview_16x16.gif ', Leaf:true,id: ' 1_5 ', Checked:false},{text: ' 8 ', Icon: ' Sysimg/icon/upload.gif ', Leaf:true,id: ' 1_7 ', Checked:false},{text: ' 9 ', Icon: ' sysimg/icon/ Users--exclamation.gif ', Leaf:true,id: ' 1_8 ', Checked:false},{text: ' Ten ', Icon: ' Sysimg/icon/pixies_020.gif ', leaf: True,id: ' 1_9 ', Checked:false}]},{expanded:true,text: ' B ', Children:[{text: ' One ', Icon: ' Sysimg/icon/pixies_023.gif ', Leaf:true,id: ' 2_1 ', CHECKED:FALse},{text: ' B ', icon: ' Sysimg/icon/pixies_017.gif ', Leaf:true,id: ' 2_2 ', Checked:false}]},{expanded:true,text: ' C ', Children:[{text: ' + ', Icon: ' Sysimg/icon/users--arrow.gif ', Leaf:true,id: ' 3_1 ', Checked:false},{text: ' + ', Icon: ' Sysimg/icon/users.gif ', Leaf:true,id: ' 3_2 ', Checked:false},{text: ' The ', ' icon: ' Sysimg/icon/hammer.gif ', leaf:true,id : ' 3_3 ', Checked:false},{text: ' + ', Icon: ' Sysimg/icon/bandaid--arrow.gif ', Leaf:true,id: ' 3_4 ', Checked:false},{text : ' + ', Icon: ' Sysimg/icon/user_go.gif ', Leaf:true,id: ' 3_5 ', Checked:false},{text: ' + ', Icon: ' Sysimg/icon/cog.gif ', Leaf:true,id: ' 3_6 ', Checked:false},{text: ' + ', Icon: ' Sysimg/icon/publish.gif ', Leaf:true,id: ' 3_7 ', checked:false}, {text: ' A ', icon: ' Sysimg/icon/users--exclamation.gif ', Leaf:true,id: ' 3_8 ', Checked:false},{text: ' + ', Icon: ' Sysimg /icon/user-black.gif ', Leaf:true,id: ' 3_9 ', Checked:false},{text: ' $ ', Icon: ' Sysimg/icon/leaf.gif ', Leaf:true,id: ' 3 _10 ', Checked:false}]}]}), listeners:{' Itemcontextmenu ': function (menutree,record,items,index,e) { E.preventdefault (); E.stopevENT ();//infer if the leaf node if (record.data.leaf==false) {var nodemenu = new Ext.menu.Menu ({floating:true,items:[{text: ' Select All ', Handler:function () {for (var i =0;i<record.data.children.length;++i) {//Set node Checked property is Truerecord.childnodes[i]. Set (' checked ', true);}}},{text: ' Anti-select ', Handler:function () {for (var i =0;i<record.data.children.length;++i) {if ( Record.childnodes[i].data.checked = = False) {//Set node checked property to Truerecord.childnodes[i].set (' checked ', true)}else {// Set the node checked property to Truerecord.childnodes[i].set (' checked ', false),}}}},{text: ' Revoke all ', handler:function () {for (var i =0;i <record.data.children.length;++i) {//Set node checked attribute is Falserecord.childnodes[i].set (' checked ', false);}}}); Nodemenu.showat (E.getxy ());}}});


Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

ExtJS 4.2 Right-click menu tree Node (, select Inverse, repeal)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.