my mistake, the error message for attempt 2 (e.g. 
myGrid.columns.source[0].sortDescending=false;) was a compile error:

1119: Access of possibly undefined property source through a reference with 
static type 
 mx.collections:IList


----- Original Message -----
From: [email protected]
To: [email protected]
Sent: Thursday, May 2, 2013 10:03:00 AM
Subject: Re: programmatic sort for Spark datagrid, accounting for sort triangle 
state

Thanks Alex, for the recommendation for visibleSortIndicatorIndices. And thanks 
Julio for the code implementing it (I wasn't sure how to do it). 

Attempt 1: 

private function redrawGrid():void { 
arrCol.sort=null; 
arrCol.refresh(); 
myGrid.columnHeaderGroup.visibleSortIndicatorIndices = new <int>[0]; 
myGrid.columns[0].sortDescending= true; // or false for ascending arrow 
} 

This produces a run time error: 

ReferenceError: Error #1069: Property 0 not found on mx.collections.ArrayList 
and there is no default value. 

Using FB's debugger, there's no array of columns, and sortDescending appears 
under source. So... 


Attempt 2: 

private function redrawGrid():void { 
arrCol.sort=null; 
arrCol.refresh(); 
myGrid.columnHeaderGroup.visibleSortIndicatorIndices = new <int>[0]; 
myGrid.columns.source[0].sortDescending= true; // or false for ascending arrow 
} 

This also produces the exact same error, even though I can see the property 

myGrid.columns.source[0].sortDescending=false 

when evaluating FB's Expressions tab in the debugger. That's funny... 


Attempt 3: 

private function redrawGrid():void { 
arrCol.sort=null; 
arrCol.refresh(); 
myGrid.columnHeaderGroup.visibleSortIndicatorIndices = new <int>[0]; 
col1.sortDescending= true; // or false for ascending arrow 
} 
... 
<s:GridColumn id="col1" dataField="c1"/> 

This produces the desired result! (I can't believe my eyes...) 

Thanks so much!!! I'll see if I can work a solution using this trick... 


----- Original Message ----- 
From: "Julio Carneiro" <[email protected]> 
To: [email protected] 
Sent: Thursday, May 2, 2013 9:32:00 AM 
Subject: Re: programmatic sort for Spark datagrid, accounting for sort triangle 
state 

Try this: 

> private function redrawGridLater():void { 
> arrCol.sort=null; 
> arrCol.refresh(); 
> myGrid.columnHeaderGroup.visibleSortIndicatorIndices = new <int>[0]; 
myGrid.columns[0].sortDescending= true; // or false for ascending arrow 
> } 


hth 
julio 

On May 2, 2013, at 12:11 PM, [email protected] wrote: 

> I also tried: 
> 
> private function redrawGrid():void { 
> groupId.removeElement(myGrid); 
> callLater(redrawGridLater); 
> } 
> 
> private function redrawGridLater():void { 
> groupId.addElement(myGrid); 
> } 
> 
> but same problem ... the sort arrow is still displayed. 
> 
> Is there some way to wipe myGrid out of memory (or some other idea), then 
> create it again (from scratch)? 
> 
> 
> ----- Original Message ----- 
> From: [email protected] 
> To: [email protected] 
> Sent: Thursday, May 2, 2013 7:56:12 AM 
> Subject: Re: programmatic sort for Spark datagrid, accounting for sort 
> triangle state 
> 
> Correct, it does not work. More specifically, if I use: 
> 
> private function redrawGrid():void { 
> arrCol.sort=null; 
> arrCol.refresh(); 
> } 
> 
> the sort correctly resets, but the sort arrow is not updated or changed in 
> any way. 
> 
> ----- Original Message ----- 
> From: "Tom Chiverton" <[email protected]> 
> To: [email protected] 
> Sent: Thursday, May 2, 2013 7:48:00 AM 
> Subject: Re: programmatic sort for Spark datagrid, accounting for sort 
> triangle state 
> 
> On 02/05/2013 15:44, [email protected] wrote: 
>> The thinking is, when the datagrid is first drawn, there is no sort arrow 
>> displayed, even though the first column is sorted by default. How do I get 
>> back to this scenario AFTER the datagrid is first drawn? 
> Does removing the Sort from the underlying dataProvider not work ? 
> 
> Tom 

-- 
Julio Carneiro 


Reply via email to