Flex DataGrid sorting problem - sorts even when no sort necessary
Noticed a small sorting problem in a DataGrid we are using.
When a DataGrid column header is clicked, the default alternating ascending/descending sorting takes place. Fine. But when all of the row items in a column are the same, and the column header is clicked, some sorting still takes place, but only for the first click, and this not occur on subsequent clicks.
Example can be 开发者_C百科run here: http://megaswf.com/serve/1103850 Click the 'In Stock' heading to see the problem.
<?xml version="1.0"?>
<!-- dpcontrols/DataGridSort.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
initialize="initDP();" width="550" height="400">
<mx:Script>
<![CDATA[
import mx.collections.*;
private var myDPColl:ArrayCollection;
// The data source that populates the collection.
private var myDP:Array = [
{Artist:'Pavement', Album:'Slanted and Enchanted',
Price:11.99, InStock: true},
{Artist:'Pavement', Album:'Crooked Rain, Crooked Rain',
Price:10.99, InStock: true},
{Artist:'Pavement', Album:'Wowee Zowee',
Price:12.99, InStock: true},
{Artist:'Asphalt', Album:'Brighten the Corners',
Price:11.99, InStock: true},
{Artist:'Asphalt', Album:'Terror Twilight',
Price:11.99, InStock: true},
{Artist:'Asphalt', Album:'Buildings Meet the Sky',
Price:14.99, InStock: true},
{Artist:'Other', Album:'Other', Price:5.99, InStock: true}
];
//Initialize the DataGrid control with sorted data.
private function initDP():void {
myDPColl = new ArrayCollection(myDP);
myGrid.dataProvider=myDPColl;
}
]]>
</mx:Script>
<mx:DataGrid id="myGrid" width="100%" height="213">
<mx:columns>
<mx:DataGridColumn minWidth="120" dataField="Artist" />
<mx:DataGridColumn minWidth="200" dataField="Album" />
<mx:DataGridColumn width="75" dataField="Price" />
<mx:DataGridColumn width="75" dataField="InStock"
headerText="In Stock"/>
</mx:columns>
</mx:DataGrid>
</mx:Application>
I think,this post answers the scenario.
Flex:Problems in DataGrid default sorting
精彩评论