I wanted to update my datagrid / arraycollection with data coming from server. the list is sorted by date field by default. if the record item exists in the list, i will replace the existing item with the new one, and if its not on the list, I will add it to the list.
Here is the catch, updates should be done by insert sort using uniqueId field while additions done by insert sort using the date field. How do I accomplish this? I've tried creating two sets of Sort/ICollectionView/IViewCursor, one for update and another for addition. Unfortunately it did not work. Arent these "views" and "cursors" only a virtual window to the actual collection data? -----is this the right way to do it?----------------------- var sortByUniqueKey:Sort = new Sort(); sortByUniqueKey.fields = [new SortField("uniqueId")]; var sortByStartTime:Sort = new Sort(); sortByStartTime.fields = [new SortField("dateField")]; var viewSortedByUniqueKey:ICollectionView = new ArrayCollection(items.toArray()); viewSortedByUniqueKey.sort = sortByUniqueKey; viewSortedByUniqueKey.refresh(); var viewSortedByStartTime:ICollectionView = new ArrayCollection(items.toArray()); viewSortedByStartTime.sort = sortByStartTime; viewSortedByStartTime.refresh(); var forUpdateCursor:IViewCursor = viewSortedByUniqueKey.createCursor(); var forAdditionCursor:IViewCursor = viewSortedByStartTime.createCursor(); ....do stuff here on individual cursors ... --------------------------------------------------------------------- I noticed calling ICViewSortedByUniqueKey.refresh() and ICViewSortedByUniqueId.refresh() affects the same reference collection. Any ideas? --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.