【问题标题】:Flex s:datagrid sorting doesn't seem to workFlex s:datagrid 排序似乎不起作用
【发布时间】:2012-02-18 18:13:04
【问题描述】:

我正在使用 Flashbuilder 4.6,但无法对 s:DataGrid 中的列进行排序,单击列没有任何作用。任何人都可以提出什么问题吗?

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:DataGrid x="30" y="24" requestedRowCount="4" sortableColumns="true">
        <s:columns>
            <s:ArrayList>
                <s:GridColumn dataField="dataField1" headerText="Column 1"></s:GridColumn>
                <s:GridColumn dataField="dataField2" headerText="Column 2"></s:GridColumn>
                <s:GridColumn dataField="dataField3" headerText="Column 3"></s:GridColumn>
            </s:ArrayList>
        </s:columns>
        <s:typicalItem>
            <fx:Object dataField1="Sample Data" dataField2="Sample Data" dataField3="Sample Data"></fx:Object>
        </s:typicalItem>
        <s:ArrayList>
            <fx:Object dataField1="4" dataField2="c" dataField3="data1"></fx:Object>
            <fx:Object dataField1="2" dataField2="d" dataField3="data2"></fx:Object>
            <fx:Object dataField1="1" dataField2="a" dataField3="data3"></fx:Object>
            <fx:Object dataField1="3" dataField2="b" dataField3="data4"></fx:Object>
        </s:ArrayList>
    </s:DataGrid>

</s:Application>

【问题讨论】:

    标签: apache-flex sorting datagrid flash-builder


    【解决方案1】:

    这是因为您的dataProvider 的类型应更改为ArrayCollectionArrayList 基本上是 ArrayCollection 的“轻量级”版本,去掉了排序和过滤功能,当您单击列标题进行排序时,DataGrid 在后台使用这些功能。

    【讨论】:

    • 谢谢,非常准确的回答。
    • 好答案意味着好问题:所以也为这个问题投票:-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-19
    • 2010-10-12
    • 2017-11-30
    • 2016-11-29
    相关资源
    最近更新 更多