Flex s:datagrid排序似乎不起作用
我使用的是 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
这是因为您应该将
dataProvider
的类型更改为ArrayCollection
。ArrayList
基本上是ArrayCollection
的“较轻”版本,删除了排序和过滤功能,当您单击列时,DataGrid
在后台使用这些功能用于排序的标题。It's because of the type of your
dataProvider
which you should change toArrayCollection
.ArrayList
is basically a "lighter" version ofArrayCollection
stripped of sort and filter functionalities and those are used in the background byDataGrid
when you click column header for sorting.