Ah, I read it wrong then...
 
The problem is that the component/object will be created/completed well before 
the data is populated.  I've also removed the header from the function 
(header="0") and I actually only have one "visible" column in the datagrid.  
I'm using the dataGrid as sort of an advanced list object.
 
Is there a way to sort as items are placed in the arraycollection?

________________________________

From: flexcoders@yahoogroups.com on behalf of valdhor
Sent: Thu 7/1/2010 8:11 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: datagrid column sorting


  

Are you expecting the datagrid to sort when first shown or when you click on 
the column header? The code you have will only be called when you click on the 
column header.

To sort when first shown you will need a creation complete function where you 
would create a new sort and refresh.

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , 
"Scott" <h...@...> wrote:
>
> Take this scenario:
> 
> 
> 
> .....
> 
> 
> 
> [Bindable] public var acAppts:ArrayCollection = new ArrayCollection();
> 
> 
> 
> private function sortDate(itemA:Object, itemB:Object):int 
> 
> {
> 
> return ObjectUtil.dateCompare( itemA.dtCreated,itemB.dtCreated);
> 
> }
> 
> 
> 
> 
> 
> .......
> 
> 
> 
> <mx:DataGrid x="0" y="20" width="{CELLWIDTH}" height="80" id="dgAppts"
> headerHeight="0" dataProvider="{acAppts}" wordWrap="true"
> editable="false" disabledColor="#c3c7c7" enabled="{!bDisabled}"
> visible="{!bDisabled}" itemRollOut="deleteToolTip(event)"
> 
> itemRollOver="createToolTip(event)"
> itemClick="ShowReservationDetails();" change="sortArray()" >
> 
> <mx:columns>
> 
> <mx:DataGridColumn dataField="szReservation"/> 
> 
> <mx:DataGridColumn dataField="dtCreated"
> sortCompareFunction="sortDate" visible="true" />
> 
> </mx:columns> 
> 
> </mx:DataGrid>
> 
> 
> 
> 
> 
> I should be sorting on the dtCreated field which is a date. However,
> it's not occurring. If I set a breakpoint on the sortDate function, it
> never gets hit.
> 
> 
> 
> I'm not sure if the reason is because the parent component populates the
> acAppts which doesn't cause a trigger for the dataGrid to run the sort
> function or what. Anyone have an idea on what is going on with this?
>





-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is 
believed to be clean. 

<<winmail.dat>>

Reply via email to