Hi there, hope someone has come across my problem and can point out
my mistake...
I have an ArrayCollection acting as the data provider for an
AdvancedDataGrid, and am saving out the data provider's sort fields
array to a SharedObject between sessions and refreshes of the data.
When I retrieve new data I grab the array of sort fields and stuff
them into the ArrayCollection's sort property like so:
private function getDefaultColumnsSort():void {
var prefs:SharedObject = SharedObject.getLocal("FogBugzModule");
// Look for a saved sort order.
if ("defaultColumnsSort" in prefs.data) {
var sort:Sort = new Sort();
sort.compareFunction = customCompare;
sort.fields = new Array();
for (var y:int = 0; y < prefs.data.defaultColumnsSort.length;
y++) {
if (prefs.data.defaultColumnsSort[y] != null) {
if ("name" in prefs.data.defaultColumnsSort[y])
{
if
(prefs.data.defaultColumnsSort[y].name != null) {
var sortField:SortField = new
SortField
(prefs.data.defaultColumnsSort[y].name, true, Boolean
(prefs.data.defaultColumnsSort[y].descending));
sort.fields.push(sortField);
}
}
}
}
// Add sort criteria to data provider.
casesArray.sort = sort;
// Sort data in data provider.
casesArray.refresh();
}
}
The problem is, the ADG does sort the data by the right columns, but...
* it's always in ascending order, even though the column headers show
the sort arrow correctly pointing down if the saved sort was descending.
* if you click on the column header to re-sort it nothing happens,
the sort arrow will flip-flop between pointing up and down as many
times as you like, but sort order is always ascending.
* The sorted column will not sort properly until I sort another
column by clicking it's header first, then it'll properly sort
ascending and descending when clicked.
The Sort object I'm assigning to the casesArray ArrayCollection above
"looks" OK, it just seems there is something not quite right in the
way the ADG uses it.
If anyone has any advice, I'd be very grateful.
Thanks,
Ian