【问题标题】:Flex DataGrid sorting problem - sorts even when no sort necessaryFlex DataGrid 排序问题 - 即使不需要排序也能排序
【发布时间】:2011-04-27 09:45:06
【问题描述】:

注意到我们正在使用的 DataGrid 中的一个小排序问题。

单击 DataGrid 列标题时,会发生默认的交替升序/降序排序。美好的。但是当一列中的所有行项都相同,并且单击列标题时,仍然会进行一些排序,但仅针对第一次单击,并且在随后的单击中不会发生这种情况。

可以在此处运行示例: http://megaswf.com/serve/1103850 点击“有货”标题查看问题。

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

【问题讨论】:

    标签: apache-flex actionscript-3 flex3


    【解决方案1】:

    我认为,这篇文章回答了这个场景。

    Flex:Problems in DataGrid default sorting

    【讨论】:

    • 嘿,谢谢,这有助于回答问题。搜索年龄,但没有使用“默认”关键字。很好发现。
    猜你喜欢
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-17
    • 2011-08-21
    • 2013-05-21
    • 1970-01-01
    • 2011-05-05
    相关资源
    最近更新 更多