2 Replies Latest reply on Nov 5, 2007 12:27 PM by dataDash

    Tree list selected item has attribute

    dataDash
      I have a tree which has the following kind of structure

      2007
      - Version 1
      - - Spring
      - - Summer
      - Version 2
      - - Spring
      - - Summer

      The data for the list comes from an XML file generated by a PHP script. I need to detect if a user has clicked on a publication (in this case spring or summer) spring and summer have an attribute in XML called pub_id.

      <node label="Version 1" >
      <node label="Spring" pub_id="1"/>
      <node label="Summer" pub_id="2"/>
      </node>

      How can I detect if the current selected item has a pub_id attribute?

      Many Thanks
        • 1. Re: Tree list selected item has attribute
          ntsiii Level 3
          See "hasOwnProperty".

          Also, using xml.attribute("pub_id") will not error if there is no such attribute, but will return an empty XMLList.

          Tracy
          • 2. Re: Tree list selected item has attribute
            dataDash Level 1
            Thanks for the reply Tracy, I came up with this since posting

            private function changeEvt(event:Event):void {
            if (event.currentTarget.selectedItem.@pub_id != undefined) {
            mx.controls.Alert.show("Publication Selected");
            } else {
            mx.controls.Alert.show("Not a publication");
            }
            }

            I'm just learning programing/flex and wondered which method - yours or the above is preferable or if its six of one and half a dozen of the other.

            Many thanks again!