[英]How can i sort months using SortField in Flex3?
I am sorting xmllist profilexml. 我正在对xmllist profilexml进行排序。 In the list dates and months are sorted using
SortField
. 在列表中,日期和月份使用
SortField
排序。 It is sorting up to September month. 截至9月。 After that Oct, Nov, and Dec are coming and displaying on the top in the datagrid.
在那之后的十月,十一月和十二月将要出现在数据网格的顶部。
finalList = new XMLListCollection(profileXml);
var sortL:Sort = new Sort();
sortL.fields = [new SortField("startDate", true)];
finalList.sort = sortL;
finalList.refresh();
popupProfile.dataGrid.dataProvider = finalList;
My XmlList is in this format: <startDate>1/11/2011</startDate>
. 我的XmlList的格式为:
<startDate>1/11/2011</startDate>
。
<startDate>2/15/2011</startDate>
as per my understanding it is sorting until 0-9 numeric fields only. 根据我的理解,
<startDate>2/15/2011</startDate>
只能排序到0-9个数字字段。 Is there anything I need to add in this code for numeric sorting? 我需要在此代码中添加任何内容以进行数字排序吗?
You could try a couple of things: 您可以尝试以下几种方法:
[SortField][1]
to true. [SortField][1]
的numeric属性设置为true。 sortL.fields= [new SortField("startDate", true, false, true)];
Convert your date from a string into an actual Date object before performing the sort. 在执行排序之前,将日期从字符串转换为实际的Date对象。
If you're sorting in a DataGrid
, you can use your own sortCompareFunction
. 如果要在
DataGrid
排序,则可以使用自己的sortCompareFunction
。 FlexExamples has an example for this one. FlexExamples对此有一个示例 。
This question might also help. 这个问题可能也有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.