简体   繁体   中英

How can i sort months using SortField in Flex3?

I am sorting xmllist profilexml. In the list dates and months are sorted using SortField . It is sorting up to September month. 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> .

<startDate>2/15/2011</startDate> as per my understanding it is sorting until 0-9 numeric fields only. Is there anything I need to add in this code for numeric sorting?

You could try a couple of things:

  • Set the numeric property of your [SortField][1] to true.

sortL.fields= [new SortField("startDate", true, false, true)];

  • Convert your date from a string into an actual Date object before performing the sort.

  • If you're sorting in a DataGrid , you can use your own sortCompareFunction . FlexExamples has an example for this one.

  • This question might also help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM