flex tree的相應操作

來源:互聯網
上載者:User

1. /*=========flex tree的展開,關閉,添加、刪除子節點=========*/<br /> 2. /*=========因為用的待用資料,所以並沒有真正的刪除=========*/<br /> 3. <?xml version="1.0" encoding="utf-8"?><br /> 4. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="flexlib.controls.*" xmlns:ns2="flexlib.containers.*" width="100%" height="100%" xmlns:commont="commont.*"><br /> 5. <mx:Tree x="10" y="10" width="199" height="327" labelField="@label" id="tree"<br /> 6. creationComplete="load()" fontSize="14"></mx:Tree><br /> 7.<br /> 8. <mx:XMLList id="treeData"><br /> 9. <node label="Mail Box" id="1"><br /> 10. <node label="Inbox" id="101"><br /> 11. <node label="Marketing" id="10101"/><br /> 12. <node label="Product Management" id="10102"/><br /> 13. <node label="Personal" id="10103"/><br /> 14. </node><br /> 15. <node label="Outbox" id="2"><br /> 16. <node label="Professional" id="201"/><br /> 17. <node label="Personal" id="202"/><br /> 18. </node><br /> 19. <node label="Spam" id="3"/><br /> 20. <node label="Sent" id="4"/><br /> 21. </node><br /> 22. </mx:XMLList><br /> 23.<br /> 24. <mx:Script><br /> 25. <!--[CDATA[<br /> 26. import mx.controls.Alert;<br /> 27. //載入樹資料來源<br /> 28. private function load():void{<br /> 29. tree.dataProvider=treeData;<br /> 30.<br /> 31. }<br /> 32. //展開所有節點<br /> 33. private function expandAll():void{<br /> 34. tree.expandChildrenOf(tree.selectedItem,true);<br /> 35.<br /> 36. }<br /> 37. //關閉所有節點<br /> 38. private function closeAll():void{<br /> 39. tree.openItems=[];<br /> 40. }<br /> 41. //添加子節點<br /> 42. private function addNode():void{<br /> 43. var xml:XML=tree.selectedItem as XML;<br /> 44. xml.appendChild("hello");<br /> 45.<br /> 46. }<br /> 47. //刪除子節點<br /> 48. private function delNode():void{<br /> 49. tree.dataDescriptor.removeChildAt(tree.selectedItem.parent(),tree.selectedItem,tree.selectedItem.childIndex(),tree.dataProvider);<br /> 50. }<br /> 51.<br /> 52. ]]--><br /> 53. </mx:Script><br /> 54. <mx:Button x="242" y="28" label="添加節點" fontSize="14" click="addNode()"/><br /> 55. <mx:Button x="242" y="69" label="刪除節點" fontSize="14" click="delNode()"/><br /> 56. <mx:Button x="242" y="115" label="展開節點" fontSize="14" click="expandAll()"/><br /> 57. <mx:Button x="242" y="156" label="收回節點" fontSize="14" click="closeAll()"/><br /> 58. </mx:Application>  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.