lundi 23 janvier 2017

Mx Tree fails when duplicate items are added to an existing node

I'm maintaining a large legacy Flex 4.6 project which refuses to die and have run into an issue with the Mx Tree component that I have not been able to solve. The gist is that adding items to an existing node exhibits weird behavior if the items are duplicates. If the node is created with duplicate items the component behaves as expected.

For example, the image below shows the result of adding the file "AAAAA.png" multiple times to the existing node. The highlighting goes berserk and the component seems to get confused about how many items it has (have tested this).

I've tried the "refresh tree" hack (below) of resetting the data provider, etc. and I call refresh on the various backing Array Collections. I started to go down the road of replacing the Mx Tree with a Spark Tree that someone came up with but it was turning into too much time.

Before I tell the client to let go of this feature, does anyone have a thought about what the issue might be? I am more of an Actionscript than a Flex developer and don't know my way around components beyond just using them.

enter image description here

    protected function vfAddToBtn_clickHandler(event:MouseEvent):void
        if (virtualFoldersList.selectedItem == null){
  "Please select a virtual folder to add to", "Add to Virtual Folder", Alert.OK);

        } else {
            if (briefcaseData.currentSelectionsList.length > 0){
                var vf:VirtualFolder = virtualFoldersList.selectedItem as VirtualFolder;

                if (vf != null){

                } else {
                    trace("ERROR: vfAddToBtn_clickHandler vf is null");

        private function refreshTree(tree:Tree) : void
            var selectedIndex : int = tree.selectedIndex;
            var openItems : Object = tree.openItems;
            tree.dataProvider = tree.dataProvider;
            tree.openItems = openItems;
            tree.selectedIndex = selectedIndex;

Aucun commentaire:

Enregistrer un commentaire