Thanks a bunch, 

That did work great. 
PW

--- In flexcoders@yahoogroups.com, "michael_ramirez44"
<[EMAIL PROTECTED]> wrote:
>
> --- In flexcoders@yahoogroups.com, "parkerwhirlow" 
> <parkerwhirlow@> wrote:
> >
> > DUDE! what the heck ?
> > 
> > You must have copied out the labelFunction... thats not
> > sortCompareFunction... it definitely requires two objects to 
> compare!
> > 
> > Your example implementation even does a simple number format =)
> > 
> > Nice try though.
> > PW
> > 
> > In the Language Reference, the only documentation for 
> sortCompareFunction
> > 
> > --- In flexcoders@yahoogroups.com, "michael_ramirez44"
> > <michael_ramirez44@> wrote:
> > >
> > > --- In flexcoders@yahoogroups.com, "parkerwhirlow" 
> > > <parkerwhirlow@> wrote:
> > > >
> > > > 
> > > > Its amazing how complicated something so seemingly easy can 
> be...
> > > > 
> > > > All I want to do is provide a numeric sort for columns that 
> contain
> > > > numeric data. (by default the sorting is all text based)
> > > > 
> > > > I found the DataGridColumn.sortCompareFunction and tried this.
> > > > 
> > > > The problem I have is that the objects passed to the function 
> are 
> > > the
> > > > entire row, and I have no context of which column the sort is 
> for.
> > > > 
> > > > It seems like they left out some key information in the 
> signatures 
> > > of
> > > > some of the DataGrid functions... for instance labelFunction 
> > > signature
> > > > has the column being rendered but dataTipFunction does not. 
> > > Therefore
> > > > I have the same issue with dataTipFunction as I do with
> > > > sortCompareFunction... how do you know what column you're 
> working 
> > > with?
> > > > 
> > > > Anyone know any tricks? How have others implemented custom 
> sorting 
> > > of
> > > > datagrids?
> > > > 
> > > > thanks,
> > > > PW
> > > >
> > > 
> > > The signature on the SortCompareFunction:
> > > 
> > > private function sortNumber
> (item:Object,column:DataGridColumn):String
> > > {
> > >   return numFormatter.format(item[column.dataField]);
> > > }
> > >
> >
> 
> Sorry! Your right I gave you the labelFunction. For the 
> SortCompateFunction I had to capture the headerRelease event and 
> store the column that was sorted.
> 
> <mx:DataGrid id="dgResults" dataProvider="{results}" width="100%" 
> height="100%" headerRelease="sortHeader(event)" />
> 
> private function sortHeader(event:DataGridEvent):void
> {
>     columnToSort = event.dataField;
> }
> 
> private function sortColumnNumber( x:Object, y:Object):int
> {
>     x[columnToSort] > y[columnToSort]
>     return ...
> }
>


Reply via email to