TrackTotal.numericSort should be ok.  But your compare function is using a 
variable "col" which may not be correct.

You should just be able to set the isNumeric flag on a SortFIeld and get what 
you want

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of 
markgoldin_2000
Sent: Monday, September 01, 2008 10:05 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Why this does not work?


I have a class based on DataGrid:
package CustomComponents
{
import mx.collections.*;
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.*;
import mx.events.DataGridEvent;
import mx.utils.ObjectUtil;
public class sortableDataGrid extends DataGrid
{
public function sortableDataGrid()
{
super();
addEventListener("headerRelease",
headerReleaseHeandler);
}
....
This class has a public function:
public function numericSort(itemA:Object, itemB:Object):int
{
return ObjectUtil.numericCompare(itemA[col], itemB[col]);
}

I am using this class in mxml class:
<customComponents:sortableDataGrid height="100%" enabled="true"
id="TrackTotal" verticalScrollPolicy="on"
rowHeight="22" width="100%">
<customComponents:columns>
<mx:DataGridColumn headerText="Inbound Train"
dataField="tcotid"/>
<mx:DataGridColumn headerText="Block"
dataField="tcbkcd"/>
<mx:DataGridColumn headerText="Position"
dataField="tccntl" sortCompareFunction="TrackTotal.numericSort"/>
<mx:DataGridColumn headerText="Car Initial"
dataField="tccari"/>
<mx:DataGridColumn headerText="Car Number"
dataField="tccarn"/>
<mx:DataGridColumn headerText="L/E Status"
dataField="tclest"/>
<mx:DataGridColumn headerText="Car Type"
dataField="tcctyp"/>
</customComponents:columns>
</customComponents:sortableDataGrid>

I am having problem with sortCompareFunction="TrackTotal.numericSort".
The compiler will not take sortCompareFunction="numericSort" and I
dont know why.
If I use TrackTotal.numericSort then it gets compiled but the run-
time fails with:
Error: Error #1009: Cannot access a property or method of a null
object reference.

Can someone help, please?

Reply via email to