I am attemtping to use the sortItemsOn() function as shown in the code below to make it so that after the DataProvider changes data and triggers a CollectionEvent, that the order the datagrid displays the data is descending instead of ascending.

<fx:Script>
<![CDATA[
            private function onDataGridDataChange(evt:CollectionEvent):void
            {
                Alert.show("I made it here");
                table.sortItemsOn("feature1",Array.DESCENDING)
            }

]]>
</fx:Script>
<mx:DataGrid id="table" width="100%" height="100%">
                        <mx:columns>
                            <mx:DataGridColumn dataField="@feature1`" headerText="col1"  />
                            <mx:DataGridColumn dataField="@feature2" headerText="col2" />
                        </mx:columns>
                        <mx:dataProvider>
                            {xmllist_changesEvery30Seconds}
                        </mx:dataProvider>
</mx:DataGrid>

The Alert in the function will show when the XMLList gets updated automatically, however, the sort is still the same. My end goal is to make it so that the order of the sort is descending instead of ascending. I am under the impression I might not be passing in the correct parameters. However I can't be certain. How do I use the function to have it sort in descending order after the dataProvider when the function is called in response to a change of data?

0 Answers