2011-04-27 51 views
2

注意到我們正在使用的DataGrid中的一個小排序問題。Flex DataGrid排序問題 - 即使在不需要排序的情況下也可以排序

當單擊DataGrid列標題時,會進行默認的交替升序/降序排序。精細。但是,當列中的所有行項都相同,並且列標題被點擊時,仍然會進行一些排序,但僅限於第一次點擊,並且在隨後的點擊中不會發生。

例子可以在這裏運行:http://megaswf.com/serve/1103850 點擊「庫存」的標題來看待這個問題。

enter image description here

<?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> 

回答