9 Replies Latest reply on Apr 27, 2007 2:07 PM by joelregen

    Mysterious Tree Happenings

    theLoggerGuy Level 1
      All,

      has this ever happened to you? The items in a tree go missing.

      Now unfortunately this forum lacks two main features: [code][/code] to preserve indenting and image sharing, so please accept my apologies for the external link:

      (Picture of problem)

      This looks like a bug, but I'm new here. I can't find anything that will force a redraw of the tree (short of changing the dataProvider).

      Is this a bug in my code or Flex? If it's Flex then where can I report it?
        • 1. Re: Mysterious Tree Happenings
          JohnLeger
          May I suggest that just post your code anyway. I'll just left align it. We are used to viewing the code that way in this forum. I would agree that it is unfortunate that there is no way provided to maintain indents. It would also be nice if colors were preserved too.

          John
          • 2. Re: Mysterious Tree Happenings
            theLoggerGuy Level 1
            John,

            I am happy to post the code, but I have a couple of issues and I thought I'd mention them first before committing to filling up the forum.

            1. The code, as it stands, is quite big - 280 lines (excluding the data retrieval). I don't quite know how to isolate the offending part of the code because it could be anywhere (or nowhere).
            2. The bug is inconsistent. I have been thrashing the program for a good 20 minutes before it exhibited the problem and it was slightly different this time (the white space now scrolls with the tree - last time it was static and the text scrolled under).
            3. I was really just after an opinion of whether the bug looks like a bug in the Flex component or mine. I guess you'd like to see the code to make a better determination.

            Sorry if I sound like I'm looking a gift horse in the mouth. I'm definitely appreciatively of any help.

            Also is there a way to force a refresh on a component?
            • 3. Re: Mysterious Tree Happenings
              ntsiii Level 3
              The scrolling thing is interesting. Are you on a Canvas? is there any chance some control exists with visibility false, or something like that, that could be floating over the tree?

              If you do re-assign the dataProvider, does the blank space go away?

              is data actually missing between the two visible nodes, or is this a "space".

              Tracy
              • 4. Re: Mysterious Tree Happenings
                theLoggerGuy Level 1
                Tracy,

                Structure is as follows:
                <mx:VBox>
                <mx:Panel>
                <mx:Canvas>
                <mx:HDividedBox>
                <mx:Tree/>
                </mx:HDividedBox>
                </mx:Canvas>
                </mx:Panel>
                </mx:VBox>

                I don't believe there are any other artifacts floating around and nothing is set to not display (hmm double negatives!).

                quote:

                If you do re-assign the dataProvider, does the blank space go away?

                Yes, but so does my data (because I assigned it to an empty XML data). I didn't investigate this much as it didn't seem like much of an alternative.

                quote:

                is data actually missing between the two visible nodes, or is this a "space".

                Data is still present. If I click on it then what should happen does happen, just not displayed.

                As I mentioned before it is inconsistent. The last time the tree went bad the blank spots travelled with the scrolling text, but still worked fine when clicked (though was still "hidden").
                • 5. Re: Mysterious Tree Happenings
                  ntsiii Level 3
                  Very strange. Are you on Flex 2.0.1? Grasping at straws here.

                  Can you make this happen in a test app?
                  Tracy
                  • 6. Re: Mysterious Tree Happenings
                    theLoggerGuy Level 1
                    Sorry Tracy, I was away yesterday.

                    Yes I am using 2.0.1.

                    I'm under the pump at the moment, so I can't put the time into it. But I still need some help on this behaviour, so I will post again soon.

                    Thanks for your comments so far :-)
                    • 7. Mysterious Tree Happenings
                      Goschan
                      Hi theLoggerGuy
                      Did you try the method validateNow()?

                      Quote from Help Flex Builder 2 :
                      quote:


                      validateNow () method

                      public function validateNow():void
                      Validate and update the properties and layout of this object and redraw it, if necessary. Processing properties that require substantial computation are normally not processed until the script finishes executing. For example setting the width property is delayed, because it may require recalculating the widths of the objects children or its parent. Delaying the processing prevents it from being repeated multiple times if the script sets the width property more than once. This method lets you manually override this behavior.
                      • 8. Re: Mysterious Tree Happenings
                        snafu7x7
                        I've run into a similar drawing problem with the tree that I've seen a couple of times in different situations where the tree will "double draw" itself..so for example if I had 3 nodes, I would see the same 3 nodes repeated below the original 3. Its a temporary artifact that disappears the minute you expand or collapse a node in the tree. I tired calling validateNow() on the tree in my dragComplete but to no avail.

                        The specific case I'm seeing this with is when I I drag all subnodes off a parent onto another node (I'm then left with a node without children). If I then drag a former child back to the now empty parent I get the weird redrawing thing....anyone ever seen this or know how to resolve it?

                        S
                        • 9. Re: Mysterious Tree Happenings
                          joelregen
                          have you tried calling a function like this after any alterations to the tree?

                          private function refreshTree():void{
                          tree.expandItem(rootNode, false);
                          tree.expandItem(rootNode, true);
                          }

                          this has helped with a few strange issues I have had with trees.