Flex s:datagrid排序似乎不起作用

发布于 2025-01-06 21:45:45 字数 1692 浏览 3 评论 0原文

我使用的是 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>

I'm using Flashbuilder 4.6 and can't get sorting of columns in my s:DataGrid to work, clicking on the columns does nothing. Can anyone suggest what is wrong?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

筱果果 2025-01-13 21:45:46

这是因为您应该将 dataProvider 的类型更改为 ArrayCollectionArrayList 基本上是 ArrayCollection 的“较轻”版本,删除了排序和过滤功能,当您单击列时,DataGrid 在后台使用这些功能用于排序的标题。

It's because of the type of your dataProvider which you should change to ArrayCollection. ArrayList is basically a "lighter" version of ArrayCollection stripped of sort and filter functionalities and those are used in the background by DataGrid when you click column header for sorting.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文