Thanks Valdhor and Thanks to Mark for all your help. I finally got this to work.
Kind regards. Angelo ________________________________ From: valdhor <valdhorli...@embarqmail.com> To: flexcoders@yahoogroups.com Sent: Saturday, 23 May, 2009 2:07:18 Subject: [flexcoders] Re: modify item before binding to datagrid This is how I would do it.. <mx:DataGrid id="MydataGrid" creationComplete= "getGridData( );" width="100%" height="100% " visible="false" dataProvider= "{_xmlData. *}" itemClick="getDataI tems();"> <mx:columns> <mx:DataGridColumn headerText=" ID" dataField="Supplier ID" width="30" sortCompareFunction ="IDCompare" /> <mx:DataGridColumn headerText=" Company Name" dataField="CompanyN ame" width="100"/> <mx:DataGridColumn headerText=" Contact Name" dataField="ContactN ame" width="100"/> <mx:DataGridColumn headerText=" Contact Title" dataField="ContactT itle" width="50"/> <mx:DataGridColumn headerText=" Address" dataField="Address" width="150"/> </mx:columns> </mx:DataGrid> private function IDCompare(itemA: Object, itemB:Object) :int { return ObjectUtil.numericC ompare(itemA.SupplierID, itemB.SupplierID); } --- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> wrote: > > Hi Mark, > > Thanks for your patience. I did write the import code for the ObjectUtil > class. > > But I still cannot get things properly. > > In your code, you have this.. > > return ObjectUtil.numericC ompare(itemA[ TrackTotal. col], itemB[TrackTotal. > col]); > > my dataGrid's ID is MydataGrid > > what does the col pertains to? the column id defined for the datagrid? > > Here's my datagrid mxml > > <mx:DataGrid id="MydataGrid" creationComplete= "getGridData( );" width="100%" > height="100% " visible="false" dataProvider= "{_xmlData. *}" > itemClick="getDataI tems();"> > <mx:columns> > <mx:DataGridColumn headerText=" ID" > dataField="Supplier ID" width="30"/> > <mx:DataGridColumn headerText=" Company Name" > dataField="CompanyN ame" width="100"/> > <mx:DataGridColumn headerText=" Contact Name" > dataField="ContactN ame" width="100"/> > <mx:DataGridColumn headerText=" Contact Title" > dataField="ContactT itle" width="50"/> > <mx:DataGridColumn headerText=" Address" > dataField="Address" width="150"/> > </mx:columns> > </mx:DataGrid> > > The SupplierID is the numeric column. > > But when I tried > > private function sortNumericColumn( itemA:Object, itemB:Object) : int > { > return ObjectUtil.numericC ompare(itemA[ MydataGrid. > SupplierID] , itemB[MydataGrid. SupplierID] ); > } > in the function you gave, I am getting the error: > > Access of possibly undefined property SupplierID through a reference with > static type mx.controls: DataGrid > > Thanks a bunch for your patience. > > > > > ____________ _________ _________ __ > From: markgoldin_2000 markgoldin_2000@ ... > To: flexcod...@yahoogro ups.com > Sent: Friday, 22 May, 2009 21:51:55 > Subject: [flexcoders] Re: modify item before binding to datagrid > > > > > > Of cource I meant: > import mx.utils.ObjectUtil ; > > --- In flexcod...@yahoogro ups.com, "markgoldin_ 2000" <markgoldin_ 2000@ > wrote: > > > > How about > > import.utils. ObjectUtil; > > --- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ > wrote: > > > > > > Hi Mark, > > > > > > I cannot seem to get your code working for me.. > > > > > > I am getting this error: > > > > > > Access of Undefined Property ObjectUtil.. > > > > > > I am trying to simply copy the function which you have posted. > > > > > > Any further advise? > > > > > > > > > > > > > > > ____________ _________ _________ __ > > > From: markgoldin_2000 <markgoldin_ 2000@> > > > To: flexcod...@yahoogro ups.com > > > Sent: Wednesday, 20 May, 2009 21:52:25 > > > Subject: [flexcoders] Re: modify item before binding to datagrid > > > > > > > > > > > > > > > > > > > > > > Here is what I am doing. > > > > column definition: > > > > <mx:DataGridColumn headerText=" Block" dataField="tcbkcd" > > > > sortCompareFunction ="sortNumericCol umnTrackTotal" /> > > > > and: > > > > private function sortNumericColumnTr ackTotal( itemA:Object, > > > > itemB:Object) :int > > > > { > > > > return ObjectUtil.numericC ompare(itemA[ TrackTotal. col], > > > > itemB[TrackTotal. col]); > > > > } > > > > > > > > where TrackTotal is a DG's id. > > > > > > > > HTH > > > > > > > > --- In flexcod...@yahoogro ups.com, Angelo Anolin <angelo_anolin@ ...> > > > > wrote: > > > > > > > > > > > > > > > Hi. > > > > > > > > > > I am quite new in Flex and would like to ask a simple question. > > > > > > > > > > I am retrieving datasets from a .NET webservice and binding the same > > > > > to a datagrid. The datagrid comes with a feature that when you click > > > > > on any of the headers, the column is sorted ASC or DESC. > > > > > > > > > > Now, one column which I am binding to is originally a numeric column. > > > > > But when it binds to the datagrid, it's data type becomes string. > > > > > Is it possible that prior to binding the said column to the datagrid, > > > > > I would be able to convert it back to its numeric data taype? Since > > > > > sorting the column in a string format would give a different result > > > > > as compared to sorting the same column in a numeric format. > > > > > > > > > > Thanks. > > > > > > > > > > Regards. > > > > > > > > > > > > > > >