2 Replies Latest reply on Jan 31, 2008 5:57 AM by Gregory Lafrance

    List Control

    vij010 Level 1
      Hi,

      What's the correct implementation for this sort of thing ?


      I want to add to a list. The content for the list is a user entered textbox. The contents of the textbox is put inside the list, one below the other.....I started to venture using the rowcount property, but can't get it to work....I wanted a simple alert to see the current rowcount....I have the following code....

      import mx.controls.Alert;
      import mx.controls.listClasses.ListBase;
      public function addme():void
      {
      Alert.show(String(showlist.rowCount));
      }


      But I get a constant value of 7. I don't understand how ?
        • 1. Re: List Control
          ntsiii Level 3
          You want the length of the dataProvider.

          RowCount refers to the control's visible rows. It has nothing to do with the data.

          To add an item, use the dataProvider API, probablyaddItem().

          Tracy
          • 2. Re: List Control
            Gregory Lafrance Level 6
            This may help:

            <?xml version="1.0"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">
            <mx:Script>
            <![CDATA[
            import mx.controls.Alert;
            import mx.collections.ArrayCollection;

            [Bindable]
            private var ac:ArrayCollection = new ArrayCollection;

            public function addDataHandler():void {
            ac.addItem(addData.text);
            addData.text = "";
            var dp:ArrayCollection = myList.dataProvider as ArrayCollection;
            mx.controls.Alert.show(String(dp.length));
            }
            ]]>
            </mx:Script>

            <mx:List id="myList" width="500" dataProvider="{ac}"/>
            <mx:TextArea id="addData" width="300"/>
            <mx:Button label="Add Data" click="addDataHandler()"/>
            </mx:Application>