9 Replies Latest reply on Oct 1, 2008 4:00 PM by flashharry!

    Filter Tree-view display source xml

    flashharry! Level 1
      I have a treeview that displays an xml structure.

      I converted the xml to an XMLListCollection, and ran a filter but this only filters the parent node, I need to filter children from the treeview display.

      I can make a new xml from the original only containing the data I need, however I need the xml data information for another display window when selected. I just don't want it as a tree node.

      any ideas

      Thanks

        • 1. Re: Filter Tree-view display source xml
          Level 7

          "flashharry!" <webforumsuser@macromedia.com> wrote in message
          news:gbr1c1$p0v$1@forums.macromedia.com...
          >I have a treeview that displays an xml structure.
          >
          > I converted the xml to an XMLListCollection, and ran a filter but this
          > only
          > filters the parent node, I need to filter children from the treeview
          > display.
          >
          > I can make a new xml from the original only containing the data I need,
          > however I need the xml data information for another display window when
          > selected. I just don't want it as a tree node.

          You always have access to the original parent from any node.


          • 2. Re: Filter Tree-view display source xml
            ntsiii Level 3
            XML.copy();
            Make a copy of your original, then chop away at the copy! Re-assign the copy back to your main var when you need to restore the original.

            Tracy
            • 3. Re: Filter Tree-view display source xml
              theLoggerGuy Level 1
              In a collection there is one data set, but accessed in two ways. For example if you have a list myList: XMLListCollection then you have:

              1. myList
              2. myList.source

              The first way gives you a filtered view (assuming you've applied a filter to the data. The second gives the unfilterd view - so no matter what you do to filter your data, the original data is accessed using the source property.

              Easiest way to understand it is to watch the variable in the FlexBuilder.
              • 4. Re: Filter Tree-view display source xml
                g-s-b Level 1
                I use a filter function that creates a XMLLIstCollection of only the filtered (true) items. It is disposable and is the data provider, not the original.

                • 5. Re: Filter Tree-view display source xml
                  flashharry! Level 1
                  Thinks for the input, I understand to make a copy of the xml, the filter function does not work as it only looks at the parents of the xml and not the children.

                  Here's my issue, I want display in my treeview, 3 levels parent-children of xml. There are 4th and 5th levels of the xml. I don't want them to appear in the treeview, however when a user selects one of the parent nodes in the tree, I need to get the details from the 4th and 5th level.

                  If I make copy of the xml, that grabs everything except the 4th and 5th level of the xml, when a user select one of the nodes, how do I get the data that was in level 4 and 5.

                  I hope that makes sense.

                  Thanks in advance.
                  • 6. Re: Filter Tree-view display source xml
                    Level 7

                    "flashharry!" <webforumsuser@macromedia.com> wrote in message
                    news:gbrt5l$rf$1@forums.macromedia.com...
                    > Thinks for the input, I understand to make a copy of the xml, the filter
                    > function does not work as it only looks at the parents of the xml and not
                    > the
                    > children.
                    >
                    > Here's my issue, I want display in my treeview, 3 levels parent-children
                    > of
                    > xml. There are 4th and 5th levels of the xml. I don't want them to appear
                    > in
                    > the treeview, however when a user selects one of the parent nodes in the
                    > tree,
                    > I need to get the details from the 4th and 5th level.
                    >
                    > If I make copy of the xml, that grabs everything except the 4th and 5th
                    > level
                    > of the xml, when a user select one of the nodes, how do I get the data
                    > that was
                    > in level 4 and 5.
                    >
                    > I hope that makes sense.

                    I think you can create your own data definition for a tree


                    • 7. Re: Filter Tree-view display source xml
                      ntsiii Level 3
                      Yeah, the custom DataDescriptor is probably the way to go here. I can't help with that because I have not done one.

                      I'd solve the xml problem by having an id on the 4th level nodes, and storing that id in an attribute of the 3rd level node. On click, use the id to find the child node in the main xml model and add it to the dataProvider.

                      I would really suggest checking into the Data Descriptor, for this though.

                      Tracy
                      • 8. Re: Filter Tree-view display source xml
                        manodud
                        so did u use a custom datadescriptor finally or came up with a different solution? If you used a new data descriptor, did u override the getChildren function?

                        tia
                        • 9. Re: Filter Tree-view display source xml
                          flashharry! Level 1
                          Yes I ended up using this excellent datadescriptor
                          http://snippets.dzone.com/posts/show/5673
                          and modifying it to use XMLListCollection interface.

                          This allows me to specify the node names to use as children, in this simple example visible will show up in the tree, invisible will not show but still be accessible within the XML.
                          <visible >
                          <visible>
                          <invisible />
                          </visible>
                          </visible >