简体   繁体   中英

flex: move item around in a tree control

I have a tree control and I want to give the user the ability that he can move up and down the element he just selected with a up and a downbutton. The tree gets generated from XML.

I managed to insert the selected item a second time at a other place, with the following code:

var parentXML:XML = XML(containerTree.selectedItem).parent();

var upperItem:XML = topContainer.source[containerTree.selectedIndex-1]; 

parentXML.insertChildBefore(upperItem,XML(containerTree.selectedItem));

but then I have the item there twice in the List. How can I remove to reinsert it?

Thanks for Hints! Markus

Use the delete (XML) operator to remove XML nodes .

var parentXML:XML = XML(containerTree.selectedItem).parent();

var upperItem:XML = topContainer.source[containerTree.selectedIndex-1]; 

delete containerTree.selectedItem;

parentXML.insertChildBefore(upperItem,XML(containerTree.selectedItem));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM