Below I have a quick and dirty way of making the row show up. However
if you were looking for the number to move with the item when you sort
then you need a different approach and should almost consider adding
the number to the data source. As when you sort the data grid it
actually rearranges its data source which is shown by the text box i
added. Which is always showing the contents of the first index of the
array collection.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
        <mx:Script>
                <![CDATA[
                        import mx.collections.ArrayCollection;
                        [Bindable]
                        private var acTest:ArrayCollection = new 
ArrayCollection([
                        {one: "0,1", two: "0,2"},
                        {one: "1,1", two: "1,2"},
                        {one: "2,1", two: "2,2"},
                        {one: "3,1", two: "3,2"},
                        {one: "4,1", two: "4,2"},
                        {one: "5,1", two: "5,2"}]);
                        
                        private function LabFunc(item:Object, 
column:DataGridColumn):String
                        {
                                return 
(this.acTest.getItemIndex(item).toString())
                        }
                ]]>
        </mx:Script>
        <mx:DataGrid x="10" y="10" dataProvider="{acTest}" id="grid1">
                <mx:columns>
                        <mx:DataGridColumn headerText="Column 1" 
labelFunction="LabFunc"/>
                        <mx:DataGridColumn headerText="Column 2" 
dataField="one"/>
                        <mx:DataGridColumn headerText="Column 3" 
dataField="two"/>
                </mx:columns>
        </mx:DataGrid>  
        <mx:TextInput text="{this.acTest.getItemAt(0).one+',
'+this.acTest.getItemAt(0).two}" x="320" y="9"/>
</mx:Application>



Reply via email to